kirby
MModular
•Created by Gennadiy on 12/16/2024 in #questions
Unable to use PyTorch from Mojo
I had the same issue importing PyTorch in Mojo, and it turned out the real cause was the difference in conda channels.
When I searched PyTorch on conda-forge, it showed a cpu_generic build with nomkl (which uses OpenBLAS).
On the pytorch channel, I got a CUDA build that explicitly depends on MKL (libmkl_intel_lp64.so.2).
Because of that mismatch, my environment ended up pulling in the MKL-based build even though I expected a CPU or OpenBLAS-only version. Once I made sure the channel pinned the correct PyTorch build—and either installed MKL or switched to the nomkl build—the missing-library error went away.
For anyone troubleshooting similar issues, you can see the list of available PyTorch packages in a channel using commands like:
magic search pytorch --channel pytorch
magic search pytorch --channel conda-forge
This will show the version, build string, and dependencies, which can help identify whether the package requires MKL, CUDA, or other specific libraries.33 replies