How to solve the problem:undefined reference to `cublasGetStream_v2'

XZRRRRRR: <p>When I try to compile Pytorch with Caffe2 on Ubuntu, I get one problem like this:<br>
[ 98%] Building CXX object test_tensorexpr/CMakeFiles/test_tensorexpr.dir/test_ir_printer.cpp.o<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: CMakeFiles/context_gpu_test.dir/core/context_gpu_test.cc.o: in function <code>caffe2::getStreamForHandle(cublasContext*)': context_gpu_test.cc:(.text._ZN6caffe218getStreamForHandleEP13cublasContext+0x2c): undefined reference to </code>cublasGetStream_v2’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: CMakeFiles/context_gpu_test.dir/core/context_gpu_test.cc.o: in function <code>caffe2::CUDAContext::curand_generator()': context_gpu_test.cc:(.text._ZN6caffe211CUDAContext16curand_generatorEv[_ZN6caffe211CUDAContext16curand_generatorEv]+0x56): undefined reference to </code>curandSetStream’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe211CUDAContext16curand_generatorEv[_ZN6caffe211CUDAContext16curand_generatorEv]+0xcc): undefined reference to <code>curandCreateGenerator' /home/xiangzhaorui/miniconda3/envs/swts/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe211CUDAContext16curand_generatorEv[_ZN6caffe211CUDAContext16curand_generatorEv]+0xec): undefined reference to </code>curandSetPseudoRandomGeneratorSeed’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: CMakeFiles/context_gpu_test.dir/core/context_gpu_test.cc.o: in function <code>caffe2::CUDAContextTest_TestSameThreadSameObject_Test::TestBody()': context_gpu_test.cc:(.text._ZN6caffe245CUDAContextTest_TestSameThreadSameObject_Test8TestBodyEv+0x685): undefined reference to </code>cublasCreate_v2’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe245CUDAContextTest_TestSameThreadSameObject_Test8TestBodyEv+0x6a8): undefined reference to <code>cublasSetPointerMode_v2' /home/xiangzhaorui/miniconda3/envs/swts/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe245CUDAContextTest_TestSameThreadSameObject_Test8TestBodyEv+0x6d9): undefined reference to </code>cublasSetStream_v2’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe245CUDAContextTest_TestSameThreadSameObject_Test8TestBodyEv+0x7d5): undefined reference to <code>cublasCreate_v2' /home/xiangzhaorui/miniconda3/envs/swts/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe245CUDAContextTest_TestSameThreadSameObject_Test8TestBodyEv+0x7f8): undefined reference to </code>cublasSetPointerMode_v2’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe245CUDAContextTest_TestSameThreadSameObject_Test8TestBodyEv+0x829): undefined reference to <code>cublasSetStream_v2' /home/xiangzhaorui/miniconda3/envs/swts/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe245CUDAContextTest_TestSameThreadSameObject_Test8TestBodyEv+0x935): undefined reference to </code>cublasCreate_v2’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe245CUDAContextTest_TestSameThreadSameObject_Test8TestBodyEv+0x958): undefined reference to <code>cublasSetPointerMode_v2' /home/xiangzhaorui/miniconda3/envs/swts/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe245CUDAContextTest_TestSameThreadSameObject_Test8TestBodyEv+0x985): undefined reference to </code>cublasSetStream_v2’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: CMakeFiles/context_gpu_test.dir/core/context_gpu_test.cc.o: in function <code>caffe2::CUDAContextTest_TestSameThreadDifferntObjectIfDifferentDevices_Test::TestBody()': context_gpu_test.cc:(.text._ZN6caffe267CUDAContextTest_TestSameThreadDifferntObjectIfDifferentDevices_Test8TestBodyEv+0x4d5): undefined reference to </code>cublasCreate_v2’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe267CUDAContextTest_TestSameThreadDifferntObjectIfDifferentDevices_Test8TestBodyEv+0x4f9): undefined reference to <code>cublasSetPointerMode_v2' /home/xiangzhaorui/miniconda3/envs/swts/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe267CUDAContextTest_TestSameThreadDifferntObjectIfDifferentDevices_Test8TestBodyEv+0x527): undefined reference to </code>cublasSetStream_v2’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe267CUDAContextTest_TestSameThreadDifferntObjectIfDifferentDevices_Test8TestBodyEv+0x695): undefined reference to <code>cublasCreate_v2' /home/xiangzhaorui/miniconda3/envs/swts/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe267CUDAContextTest_TestSameThreadDifferntObjectIfDifferentDevices_Test8TestBodyEv+0x6b9): undefined reference to </code>cublasSetPointerMode_v2’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe267CUDAContextTest_TestSameThreadDifferntObjectIfDifferentDevices_Test8TestBodyEv+0x6eb): undefined reference to <code>cublasSetStream_v2' /home/xiangzhaorui/miniconda3/envs/swts/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe267CUDAContextTest_TestSameThreadDifferntObjectIfDifferentDevices_Test8TestBodyEv+0x91d): undefined reference to </code>cublasCreate_v2’<br>
/home/xiangzhaorui/miniconda3/envs/swts/bin/…/lib/gcc/x86_64-conda-linux-gnu/10.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe267CUDAContextTest_TestSameThreadDifferntObjectIfDifferentDevices_Test8TestBodyEv+0x940): undefined reference to <code>cublasSetPointerMode_v2' /home/xiangzhaorui/miniconda3/envs/swts/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: context_gpu_test.cc:(.text._ZN6caffe267CUDAContextTest_TestSameThreadDifferntObjectIfDifferentDevices_Test8TestBodyEv+0x96d): undefined reference to </code>cublasSetStream_v2’</p>
<p>And this is the only problem that I’ve not solved. Does anyone know how to solve this?<br>
ps:I compiled with Ubuntu 18.04 anaconda cuda 11.7 gcc 10.3 g++10.3</p>

ptrblck: <aside class="quote no-group" data-username="XZRRRRRR" data-post="1" data-topic="195320">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/xzrrrrrr/48/66914_2.png" class="avatar"> XZRRRRRR:</div>
<blockquote>
<p>When I try to compile Pytorch with Caffe2 on Ubuntu</p>
</blockquote>
</aside>
<p>Caffe2 is deprecated and I don’t know if it’s still properly building as I doubt it’s tested in a variety of configurations. Are you able to build PyTorch in your setup without Caffe2 support?</p>

smth: <p>i can confirm that pytorch with caffe2 won’t build anymore. caffe2 codepath is no longer maintained and is removed from testing and builds.</p>

XZRRRRRR: <p>I just tested the compilation without CAFFE2 and it installs fine！</p>

XZRRRRRR: <p>Thanks for your answer! <img src="https://discuss.pytorch.org/images/emoji/apple/smile.png?v=12" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"></p>