0

I'm currently working on a Nvidia Jetson Nano and I'm not very familiar with Linux. I am trying to run a python file which imports a package called torch. I have installed it alongside with torchvision while following the instructions from NVIDIA here.

When I run pip list on my terminal, I am able to see torch listed as one of the packages installed. However, I am unable to run the python file due to the error seen below. When I try to run it on python shell, the same error pops up. FYI: Previously it had issues as the system was using python 2 by default but I have already fixed the path by switching to python 3 by editing the .bashrc file.

>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jiayi/.local/lib/python3.6/site-packages/torch/__init__.py", line 81, in <module>
    from torch._C import *
ImportError: libcudart.so.10.0: cannot open shared object file: No such file or directory

I have tried uninstalling and installing via pip but to no avail. When I try to install the pytorch package (following the instructions from a github repo here), an error occurs as seen below and it is due to the same issue. It is able to detect that the torch package is installed but there seems to be an internal issue.

Requirement already satisfied: torch==1.4.0 from file:///home/jiayi/jetson-inference/build/torch-1.4.0-cp36-cp36m-linux_aarch64.whl in /home/jiayi/.local/lib/python3.6/site-packages (1.4.0)
[jetson-inference]  cloning torchvision...
[sudo] password for jiayi: 
Cloning into 'torchvision-36'...
remote: Enumerating objects: 71, done.
remote: Counting objects: 100% (71/71), done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 8219 (delta 37), reused 29 (delta 15), pack-reused 8148
Receiving objects: 100% (8219/8219), 10.22 MiB | 3.60 MiB/s, done.
Resolving deltas: 100% (5631/5631), done.
[jetson-inference]  building torchvision for Python 3.6...
Traceback (most recent call last):
  File "setup.py", line 14, in <module>
    import torch
  File "/home/jiayi/.local/lib/python3.6/site-packages/torch/__init__.py", line 81, in <module>
    from torch._C import *
ImportError: libcudart.so.10.0: cannot open shared object file: No such file or directory

[jetson-inference]  installation complete, exiting with status code 0
[jetson-inference]  to run this tool again, use the following commands:

    $ cd <jetson-inference>/build
    $ ./install-pytorch.sh
Goh Jia Yi
  • 329
  • 3
  • 16

2 Answers2

1

I meet the exact same problem. The problem seems to be cuda 10.2. Downgrading to 10.0 does not help either. Probably the solution is to manually install everything from Jetpack and making sure that the cuda version to be installed is 10.0.

Leo
  • 11
  • 1
0

You can check whether you have installed the correct version of torch that supports you cuda by checking torch.version.cuda and ensuring it is the same cuda version as on your jetson nano.

An easier way to install torch would be to download the .whl files from Jetson Zoo. It may also be useful to upgrade your nano to the latest Jetpack versions

Yi Hang Tay
  • 166
  • 8
  • When I run `torch.version.cuda` on the terminal it gives me `bash: torch.version.cuda: command not found`. It shouldn't be the case, I was wondering if you know why because I'm not really familiar with it. – Goh Jia Yi May 22 '20 at 05:06
  • On your command line, please do 2 things. `nvcc -V` This will show the installed cuda on your nano. Next, enter your python and find torch cuda version by doing the following. `python3` `import torch` `torch.version.cuda`. This will show your torch cuda version. Please ensure that both of them match up – Yi Hang Tay May 22 '20 at 05:27
  • I was able to run `nvcc -V`. However, when I try to run `import torch` on my python shell it gives the error as listed in the original question (first code chunk). This happens when I open the shell via `python` or `python3`. – Goh Jia Yi May 22 '20 at 05:34
  • Just out of curiosity, what is the output of your `nvcc -V` – Yi Hang Tay May 22 '20 at 05:50
  • Here you go: nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2019 NVIDIA Corporation Built on Wed_Oct_23_21:14:42_PDT_2019 Cuda compilation tools, release 10.2, V10.2.89 – Goh Jia Yi May 22 '20 at 06:17
  • So it looks like you have CUDA 10.2 installed but torch is expected CUDA 10.0. You can either find a pytorch that supports 10.2 or downgrade your installed CUDA to 10.0 – Yi Hang Tay May 22 '20 at 06:23
  • Thanks for your help but I believe there must be an additional issue. This is because in the link provided by Cohen [here](https://github.com/rusty1s/pytorch_geometric/issues/114), others have uncompatible pytorch and cuda versions but they are still able to run `import torch` and `torch.version.cuda` without having an error which I'm unable to so. Because I'm using pip and not conda (on the jetson nano), a lot of the solutions online are not applicable. – Goh Jia Yi May 22 '20 at 10:03
  • you can do a quick sanity check by seeing whether this file exists `/usr/local/cuda-10.0/lib64/libcudart.so.10.0` If it doesnt, it means that the file is really missing. – Yi Hang Tay May 22 '20 at 10:13