Docker build on Jetson Xavier

I’m trying to build a docker image that uses pytorch. I use the existing image as the base, but it cannot run a simple command. My Dockerfile is:


SHELL ["/bin/bash", "-c"]


RUN python3 -c 'import torch;print(torch.cuda.is_available());print(torch.cuda.get_device_name(torch.cuda.current_device()));'

A docker build . command creates the following error:

@nvidia-edge:~/Git/Docker$ docker build .
Sending build context to Docker daemon   2.56kB
Step 1/4 : FROM
 ---> f27ad092c6d1
Step 2/4 : SHELL ["/bin/bash", "-c"]
 ---> Running in 0ec8104a16cf
Removing intermediate container 0ec8104a16cf
 ---> f85c5aa20ecf
Step 3/4 : RUN echo $SHELL
 ---> Running in f38447fba45b
Removing intermediate container f38447fba45b
 ---> 45fdad818599
Step 4/4 : RUN python3 -c 'import torch;print(torch.cuda.is_available());print(torch.cuda.get_device_name(torch.cuda.current_device()));'
 ---> Running in 0f50227984c6
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/torch/", line 189, in <module>
  File "/usr/local/lib/python3.6/dist-packages/torch/", line 142, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File "/usr/lib/python3.6/ctypes/", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: cannot open shared object file: No such file or directory
The command '/bin/bash -c python3 -c 'import torch;print(torch.cuda.is_available());print(torch.cuda.get_device_name(torch.cuda.current_device()));'' returned a non-zero code: 1

Am I missing something?

Thank you

1 Like

Hi @giannisp, since you are trying to use CUDA during building the container, have you set your Docker daemon’s default-runtime to nvidia?

See here to enable it:

Remember to reboot or restart your Docker service after making the changes.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.