libpython-clj icon indicating copy to clipboard operation
libpython-clj copied to clipboard

the problem to access nested Python attributes or methods **(py.. torch/backends mps is_available)**.

Open Thinking-Functionally opened this issue 7 months ago • 1 comments

the problem to access nested Python attributes or methods (py.. torch/backends mps is_available), Please comment how to fix it

(defn get-device []
  (try
    (let [device (torch/device (if (py.. torch/backends mps is_available)
                                 "mps"
                                 "cpu"))]
      (println "Using device:" device)
      device)
    (catch Exception e
      (println "Error initializing device:" (.getMessage e))
      (torch/device "cpu")))) ;; Fallback to CPU on error

Thinking-Functionally avatar Jun 22 '25 13:06 Thinking-Functionally

what is the error?

jjtolton avatar Jun 23 '25 00:06 jjtolton