Torch_sparse can't find nvcc

I’m trying to install torch_sparse in my environment with:

pip install torch_sparse

At first the installation could not find cuda.h, but following this topic I’ve set the CUDA_HOME variable to my environment directory. After that I get the error message below (end of message), complaining about not finding nvcc. I’ve searched for my nvcc and its actual address is at the anaconda3 bin dir: /mnt/LINUX_DADOS/anaconda3/bin/nvcc

Can/Should I copy the nvcc bin, or should I set another variable before running pip?

I’ve followed the steps in this video to install nvcc, cudatoolkit and pytorch:

conda install -c nvidia cuda-nvcc
conda install -c anaconda cudatoolkit
conda install pytorch torchvision torchaudio pytorch-cuda -c pytorch -c nvidia

Thanks in advance,

Collecting torch_sparse
Using cached torch_sparse-0.6.18.tar.gz (209 kB)
Preparing metadata (setup.py) … done
Requirement already satisfied: scipy in /mnt/LINUX_DADOS/anaconda3/envs/difusco/lib/python3.12/site-packages (from torch_sparse) (1.13.0)
Requirement already satisfied: numpy<2.3,>=1.22.4 in /mnt/LINUX_DADOS/anaconda3/envs/difusco/lib/python3.12/site-packages (from scipy->torch_sparse) (1.26.4)
Building wheels for collected packages: torch_sparse
Building wheel for torch_sparse (setup.py) … error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [53 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-312
creating build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/index_select.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/spmm.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/cat.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/rw.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/convert.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/coalesce.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/bandwidth.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/tensor.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/storage.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/spspmm.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/spadd.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/typing.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/metis.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/saint.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/transpose.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/matmul.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/add.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/utils.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/mul.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/testing.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/masked_select.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/diag.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/reduce.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/permute.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/eye.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/sample.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/select.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/narrow.py → build/lib.linux-x86_64-cpython-312/torch_sparse
copying torch_sparse/init.py → build/lib.linux-x86_64-cpython-312/torch_sparse
running egg_info
writing torch_sparse.egg-info/PKG-INFO
writing dependency_links to torch_sparse.egg-info/dependency_links.txt
writing requirements to torch_sparse.egg-info/requires.txt
writing top-level names to torch_sparse.egg-info/top_level.txt
reading manifest file ‘torch_sparse.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no previously-included files matching ‘’ found under directory ‘third_party/parallel-hashmap/css’
warning: no previously-included files matching '
’ found under directory ‘third_party/parallel-hashmap/html’
warning: no previously-included files matching ‘’ found under directory ‘third_party/parallel-hashmap/tests’
warning: no previously-included files matching '
’ found under directory ‘third_party/parallel-hashmap/examples’
warning: no previously-included files matching ‘’ found under directory ‘third_party/parallel-hashmap/benchmark’
warning: no previously-included files matching '
’ found under directory ‘test’
warning: no previously-included files matching ‘*’ found under directory ‘benchmark’
adding license file ‘LICENSE’
writing manifest file ‘torch_sparse.egg-info/SOURCES.txt’
running build_ext
error: [Errno 2] No such file or directory: ‘/mnt/LINUX_DADOS/anaconda3/envs/difusco/bin/nvcc’
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for torch_sparse
Running setup.py clean for torch_sparse
Failed to build torch_sparse
ERROR: Could not build wheels for torch_sparse, which is required to install pyproject.toml-based projects

I would recommend installing a full CUDA toolkit locally, instead of the conda pieces, if you want to build this library from source.

Thank you for the reply!

I’ve installed the CUDA toolkit locally, following this [guide](CUDA Toolkit 12.4 Update 1 Downloads | NVIDIA Developer, and nvcc seems to be working (after I’ve set the cuda bin directory to the path).

I don’t want to build anything from source if I don’t have to. Are you saying I should? In this case, which guide should I follow?

Your command tries to build the library from soure, otherwise nvcc wouldn’t be needed.
pytorch_sparse shows the command to install the binaries in their README.

Thank you,

I’ve installed pytorch_sparse according to the README and it worked.