Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot initialize CUDA without ATen_cuda library #216

Closed
pharrellyhy opened this issue Jun 19, 2018 · 2 comments
Closed

cannot initialize CUDA without ATen_cuda library #216

pharrellyhy opened this issue Jun 19, 2018 · 2 comments

Comments

@pharrellyhy
Copy link

pharrellyhy commented Jun 19, 2018

Just want to test if CUDA part is working properly using below code but got errors. I linked both cpu and cuda libraries. The cpu part is working fine. Any idea on this?

cout << ones(CUDA(kFloat), {3,4}) << "\n";

TARGET_LINK_LIBRARIES(test_aten ${CUDA_LIBRARIES} ${ATen_BINARY_DIR}/src/ATen/libATen_cuda.so ${ATen_BINARY_DIR}/src/ATen/libATen_cpu.so)

terminate called after throwing an instance of 'at::Error'
what(): cannot initialize CUDA without ATen_cuda library (initCUDA at /home/pharrell/downloads/ATen/aten/src/ATen/detail/CUDAHooksInterface.h:42)
frame #0: at::Context::lazyInitCUDA()::{lambda()#1}::operator()() const + 0x32 (0x409a56 in ./test_aten)
frame #1: void std::_Bind_simple<at::Context::lazyInitCUDA()::{lambda()#1} ()>::_M_invoke<>(std::_Index_tuple<>) + 0x28 (0x40afb0 in ./test_aten)
frame #2: std::_Bind_simple<at::Context::lazyInitCUDA()::{lambda()#1} ()>::operator()() + 0x2c (0x40ace0 in ./test_aten)
frame #3: void std::__once_call_impl<std::_Bind_simple<at::Context::lazyInitCUDA()::{lambda()#1} ()> >() + 0x17 (0x40a7a4 in ./test_aten)
frame #4: + 0xea99 (0x7fe48d128a99 in /lib/x86_64-linux-gnu/libpthread.so.0)
frame #5: ./test_aten() [0x408ccd]
frame #6: void std::call_onceat::Context::lazyInitCUDA()::{lambda()#1}(std::once_flag&, at::Context::lazyInitCUDA()::{lambda()#1}&&) + 0x77 (0x40a0f7 in ./test_aten)
frame #7: at::Context::lazyInitCUDA() + 0x3d (0x409b37 in ./test_aten)
frame #8: at::Context::initCUDAIfNeeded(at::Backend) + 0x21 (0x409b81 in ./test_aten)
frame #9: at::Context::getTypeOpt(at::Backend, at::ScalarType) + 0x23 (0x40984b in ./test_aten)
frame #10: at::Context::getType(at::Backend, at::ScalarType) + 0x4a (0x40992a in ./test_aten)
frame #11: ./test_aten() [0x408da9]
frame #12: ./test_aten() [0x408de1]
frame #13: main + 0x65a (0x409467 in ./test_aten)
frame #14: __libc_start_main + 0xf0 (0x7fe48c3cc830 in /lib/x86_64-linux-gnu/libc.so.6)
frame #15: _start + 0x29 (0x408bb9 in ./test_aten)

Aborted (core dumped)

@c-hofer
Copy link

c-hofer commented Jun 21, 2018

I had a similar problem which was solved by loading the cuda verson of ATen library in my executable:

Add a line in ure main like the following

#include <dlfcn.h> //necessary to use dlopen
...
int main(){
dlopen("libcaffe2_gpu.so", RTLD_NOW);
...
}

and ensure that LD_LIBRARY_PATH makes it visible on runtime.

Note: maybe the library has a different name in pytorch 0.5.0 this one seems to be right (at least at the moment)
regards

@pharrellyhy
Copy link
Author

@c-hofer
Thanks. This works like a charm. Closing it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants