question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fail build torchvision from source for cuda support

See original GitHub issue

I tried build torchvision from source with cuda support , but appear error like below:

[ 71%] Building CUDA object CMakeFiles/torchvision.dir/torchvision/csrc/ops/cuda/deform_conv2d_kernel.cu.o
/usr/local/cuda/include/cusparse.h(6314): error: expected a "}"

Segmentation fault (core dumped)
CMakeFiles/torchvision.dir/build.make:593: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/ops/cuda/deform_conv2d_kernel.cu.o' failed
make[2]: *** [CMakeFiles/torchvision.dir/torchvision/csrc/ops/cuda/deform_conv2d_kernel.cu.o] Error 139
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/torchvision.dir/all' failed
make[1]: *** [CMakeFiles/torchvision.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

Error appears at the first cuda build package. I tried searching for a fix, but the error never seems to show up before: My environment:

Ubuntu 18.04
CUDA 11.1
CuDNN 8.2.0
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
namngduccommented, Sep 1, 2021

@prabhat00155 @fmassa Thanks for your supports Have some error when cmake did not found CUDA compiler and I don’t know why I fixed issues by adding path nvcc set(CMAKE_CUDA_COMPILER "/usr/local/cuda-11.1/bin/nvcc") to CMakeLists.txt

1reaction
prabhat00155commented, Aug 26, 2021

I was able to build torchvision from source without any error(both with libtorch 1.9.0 and latest nightly). This is what I did:

wget https://download.pytorch.org/libtorch/nightly/cu111/libtorch-cxx11-abi-shared-with-deps-latest.zip
unzip libtorch-cxx11-abi-shared-with-deps-latest.zip
mkdir install
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/fsx/users/prabhatroy/repos/libtorch -DCMAKE_INSTALL_PREFIX=/fsx/users/prabhatroy/repos/vision/install -DWITH_CUDA=on ..
make
make install

Could you please try with the latest torch nightly(libtorch 1.10.0.dev20210825+cu111)? You can either use the aforementioned wget or go to pytorch homepage page and select preview(nightly). Also, could you paste the output of the following:

cat /usr/local/cuda/version.txt
nvidia-smi
Read more comments on GitHub >

github_iconTop Results From Across the Web

build from source error · Issue #6157 · pytorch/vision - GitHub
I figured out a solution, upgrade cuda to 11.3, then install the latest version of pytorch (cudatoolkit=11.3), and then compile torchvision.
Read more >
Issue Building Torchvision from Source - PyTorch Forums
I'm building torch and torchvision from source since my system is fixed to CUDA 10.0 unfortunately and I need torch 1.6+. I am...
Read more >
Speed Up PyTorch by Building from Source on Ubuntu 18.04
As of writing, PyTorch officially supports CUDA up to 10.0 unless PyTorch adds MAGMA support for ... First, let's build the torchvision library...
Read more >
PyTorch and torchvision versions are incompatible
This can happen if your PyTorch and torchvision versions are incompatible, or if you had errors while compiling torchvision from source.
Read more >
Can't connect to GPU when building PyTorch projects
remove any Conda environments in Ubuntu. · clean the pip list and Conda list until none of any PyTorch, torchvision, Cuda etc works....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found