pytorch icon indicating copy to clipboard operation
pytorch copied to clipboard

figure out a way to load libcudart.so from it's compile-time path

Open soumith opened this issue 10 years ago • 7 comments

right now if libcudart.so is not in LD_LIBRARY_PATH, though it was found at compile-time, these lines will fail: https://github.com/pytorch/pytorch/blob/master/torch/cuda/init.py#L39-L43

Avoid this, by idk doing something...

I think i have a few good ideas.

soumith avatar Oct 22 '16 04:10 soumith

We need to add /usr/local/cuda/lib64 (or that's mac dir) to the rpath of _C

apaszke avatar Oct 22 '16 08:10 apaszke

the problem i dont think is to add it to rpath, it's because we ctypes.load

soumith avatar Oct 22 '16 15:10 soumith

Right. We could try with the default cuda installation path if it's not found from LD_LIBRARY_PATH.

apaszke avatar Oct 22 '16 23:10 apaszke

Actually, do we really want to use the compile path? We should try to detect it at runtime, right? Or are we going to ship CUDA libs in our binaries?

apaszke avatar Oct 23 '16 21:10 apaszke

we first load using runtime paths, and if it fails, fallback to path known at compile time.

soumith avatar Oct 24 '16 14:10 soumith

I fear this is going to get brittle, especially if you are shipping CUDA libs. e.g. a user swaps HW and picks up a new driver and/or toolkit. As @soumith says, I'm pretty sure you want to use the runtime paths. Similarly, CUDA 7.5 won't run on Pascal and we have a cudnn built for 7.5 that will not do the right thing on CUDA 8, so those need to go together. If a user installs the CUDA bits via deb/rpm the right things are supposed to happen. If you push bits, we need to figure out how to make sure things line up. But this is perhaps a much larger packaging conversation.

thatguymike avatar Nov 01 '16 22:11 thatguymike

@thatguymike Yeah, I've implemented it to first try loading it without any path and then try /usr/local/cuda/lib64 and /usr/local/cuda/lib. I'll push the commit tomorrow.

apaszke avatar Nov 01 '16 23:11 apaszke