# Custom built Pytorch in docker

**URL:** <https://forums.developer.nvidia.com/t/custom-built-pytorch-in-docker/310806>\
**Category:** Jetson AGX Xavier\
**Tags:** pytorch\
**Created:** [October 22, 2024, 10:28pm UTC](https://forums.developer.nvidia.com/t/custom-built-pytorch-in-docker/310806 "2024-10-22T22:28:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![archie1983](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@archie1983](https://forums.developer.nvidia.com/u/archie1983)\
**Post date:** [October 22, 2024, 10:28pm UTC](https://forums.developer.nvidia.com/t/custom-built-pytorch-in-docker/310806/1 "2024-10-22T22:28:39Z")

</div>

Hi,  
I’ve got a Jetson XAVIER with JetPack 5.1.3 / L4T 35.5.0. Within my docker container I need a Pytorch version that has been built with the USE\_DISTRIBUTED=1 key. Pytorch 2.1 or 2.2 would do with an appropriate torchvision. If I build it on my laptop and then install the wheel in the docker container and then run my code, then I get the following:

File “/usr/local/lib/python3.8/dist-packages/torch/\_ops.py”, line 692, in **call**  
return self.\_op(\*args, \*\*kwargs or {})  
NotImplementedError: Could not run ‘torchvision::nms’ with arguments from the ‘CUDA’ backend. This could be because the operator doesn’t exist for this backend, or was omitted during the selective/custom build process (if using custom build).

Next step was to rebuild your container (preferebaly l4t-pytorch, but pytorch would be a good start). So I checked out jetson-containers and modified

packages/l4t/l4t-pytorch/l4t-pytorch.json

to include “build\_args”: {“USE\_DISTRIBUTED” : “1”}

Then I start the whole process with: PYTORCH\_VERSION=2.1 jetson-containers build l4t-pytorch

but unfortunately it doesn’t even try to build pytorch. It downloads a pre-built wheel and installs that.

Is there a way to force the build with the build arg I need?

Thanks

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [October 23, 2024, 7:12am UTC](https://forums.developer.nvidia.com/t/custom-built-pytorch-in-docker/310806/3 "2024-10-23T07:12:24Z")

</div>

Hi,

You can modify the Dockerfile below to make it build from the source:

> <https://github.com/dusty-nv/jetson-containers/blob/master/packages/pytorch/Dockerfile#L38>

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [November 19, 2024, 6:12am UTC](https://forums.developer.nvidia.com/t/custom-built-pytorch-in-docker/310806/5 "2024-11-19T06:12:19Z")

</div>

Closed on November 19, 2024, 6:12am UTC

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