# Problems Training Models

**URL:** <https://forums.developer.nvidia.com/t/problems-training-models/196989>\
**Category:** Jetson Nano\
**Tags:** ai-training\
**Created:** [December 3, 2021, 3:32am UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989 "2021-12-03T03:32:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![my65gto2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@my65gto2](https://forums.developer.nvidia.com/u/my65gto2)\
**Post date:** [December 3, 2021, 3:32am UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/1 "2021-12-03T03:32:20Z")

</div>

I am having problems on my jetson with training my models:  
This is the error that I am getting:(base) jetson@jetson-desktop:~/Downloads/jetson-inference/python/training/classification$ python3 train.py --model-dir=myModel ~/Downloads/jetson-inference/myTrain  
Use GPU: 0 for training  
=\> dataset classes: 3 [‘Black Nut’, ‘Leaf’, ‘Pecan’]  
=\> using pre-trained model ‘resnet18’  
=\> reshaped ResNet fully-connected layer with: Linear(in\_features=512, out\_features=3, bias=True)  
Traceback (most recent call last):  
File “/home/jetson/Downloads/jetson-inference/python/training/classification/train.py”, line 506, in   
main()  
File “/home/jetson/Downloads/jetson-inference/python/training/classification/train.py”, line 135, in main  
main\_worker(args.gpu, ngpus\_per\_node, args)  
File “/home/jetson/Downloads/jetson-inference/python/training/classification/train.py”, line 227, in main\_worker  
torch.cuda.set\_device(args.gpu)  
File “/home/jetson/mambaforge/lib/python3.9/site-packages/torch/cuda/ **init**.py”, line 311, in set\_device  
torch.\_C.\_cuda\_setDevice(device)  
AttributeError: module ‘torch.\_C’ has no attribute ‘\_cuda\_setDevice’

I may not be giving enough information. Please help me if you can.  
Thanks,  
Brent

---

<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:** [December 3, 2021, 8:28am UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/3 "2021-12-03T08:28:19Z")

</div>

Hi,

May I know how do you run the training job?  
Thanks.

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [December 3, 2021, 5:24pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/4 "2021-12-03T17:24:12Z")

</div>

> [@my65gto2](#):
>
> “/home/jetson/mambaforge/lib/python3.9/site-packages/torch/cuda/ **init**.py”

It also looks like you are using a different build of PyTorch built for Python 3.9 that was installed through Conda.

Instead, please install one of the PyTorch pip wheels from [this post](https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-10-now-available/72048) (these were built with CUDA/cuDNN enabled) or use the [l4t-pytorch](https://ngc.nvidia.com/catalog/containers/nvidia:l4t-pytorch) container.

---

<div class="post-metadata">

**Author:** ![my65gto2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@my65gto2](https://forums.developer.nvidia.com/u/my65gto2)\
**Post date:** [December 3, 2021, 6:42pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/5 "2021-12-03T18:42:09Z")

</div>

Should I uninstall PyTorch before reinstalling?

Thanks for your help,  
Brent

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [December 3, 2021, 6:46pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/6 "2021-12-03T18:46:09Z")

</div>

I’m not very familiar with using Conda (especially on Jetson), but yes I think so as to not confuse the packages.

---

<div class="post-metadata">

**Author:** ![my65gto2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@my65gto2](https://forums.developer.nvidia.com/u/my65gto2)\
**Post date:** [December 5, 2021, 8:33pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/7 "2021-12-05T20:33:39Z")

</div>

Everything works good until i get to here:

base) jetson@jetson-desktop:~$ pip3 install numpy torch-1.8.0-cp36-cp36m-linux\_aarch64.whl  
ERROR: torch-1.8.0-cp36-cp36m-linux\_aarch64.whl is not a supported wheel on this platform.

Brent

---

<div class="post-metadata">

**Author:** ![my65gto2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@my65gto2](https://forums.developer.nvidia.com/u/my65gto2)\
**Post date:** [December 5, 2021, 10:26pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/8 "2021-12-05T22:26:33Z")

</div>

Tried this also:

(base) jetson@jetson-desktop:~$ pip3 install numpy torch-1.10.0-cp36-cp36m-linux\_aarch64.whl  
WARNING: Requirement ‘torch-1.10.0-cp36-cp36m-linux\_aarch64.whl’ looks like a filename, but the file does not exist  
ERROR: torch-1.10.0-cp36-cp36m-linux\_aarch64.whl is not a supported wheel on this platform.

I am running L4t32.6.1 JetPack 4.6

Brent

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [December 6, 2021, 2:27pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/9 "2021-12-06T14:27:04Z")

</div>

> [@my65gto2](#):
>
> WARNING: Requirement ‘torch-1.10.0-cp36-cp36m-linux\_aarch64.whl’ looks like a filename, but the file does not exist

Hi @my65gto2, did you download the wheel?

What does your `pip3 --version` show? It should be for Python 3.6 because my PyTorch wheels are compiled for Python 3.6.

---

<div class="post-metadata">

**Author:** ![my65gto2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@my65gto2](https://forums.developer.nvidia.com/u/my65gto2)\
**Post date:** [December 6, 2021, 2:57pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/10 "2021-12-06T14:57:34Z")

</div>

python3.9

Thanks you!

---

<div class="post-metadata">

**Author:** ![my65gto2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@my65gto2](https://forums.developer.nvidia.com/u/my65gto2)\
**Post date:** [December 6, 2021, 2:59pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/11 "2021-12-06T14:59:21Z")

</div>

Also, if go back to python3.6, would I need to uninstall python3.9?  
Brent

python3.9

Thanks you!

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [December 6, 2021, 4:10pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/12 "2021-12-06T16:10:48Z")

</div>

> [@my65gto2](#):
>
> if go back to python3.6, would I need to uninstall python3.9?

I don’t believe so, it may be that you just need to run `pip3.6` and `python3.6` or restore the `pip3/python3` symbolic links to point to Python 3.6 versions instead.

---

<div class="post-metadata">

**Author:** ![my65gto2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@my65gto2](https://forums.developer.nvidia.com/u/my65gto2)\
**Post date:** [December 18, 2021, 7:01pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/14 "2021-12-18T19:01:33Z")

</div>

Hi Dusty,  
I did a complete re-install of jetpack. I have Pytorch up and running. I am having a problem with a program that I am running. This is the part I am getting an error:

net=jetson.inference.imageNet(‘alexnet’,[‘–model= /home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx’,‘–input\_blob=input\_0’,‘–output\_blob=output\_0’,‘–labels= /home/jetson/Downloads/jetson-inference/myTrain/labels.txt’])

This is what I get when running the program:

jetson@jetson-desktop:~/Desktop/pyPro$ /usr/bin/python3 /home/jetson/Desktop/pyPro/NVIDIA/deepLearning-10.py  
[WARN:0] global /home/nvidia/host/build\_opencv/nv\_opencv/modules/videoio/src/cap\_gstreamer.cpp (1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module source reported: Could not read from resource.  
[WARN:0] global /home/nvidia/host/build\_opencv/nv\_opencv/modules/videoio/src/cap\_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline  
[WARN:0] global /home/nvidia/host/build\_opencv/nv\_opencv/modules/videoio/src/cap\_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created  
jetson.inference – imageNet loading network using argv command line params

imageNet – loading classification network model from:  
– prototxt (null)  
– model /home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx  
– class\_labels /home/jetson/Downloads/jetson-inference/myTrain/labels.txt  
– input\_blob ‘input\_0’  
– output\_blob ‘output\_0’  
– batch\_size 1

[TRT] TensorRT version 8.0.1  
[TRT] loading NVIDIA plugins…  
[TRT] Registered plugin creator - ::GridAnchor\_TRT version 1  
[TRT] Registered plugin creator - ::GridAnchorRect\_TRT version 1  
[TRT] Registered plugin creator - ::NMS\_TRT version 1  
[TRT] Registered plugin creator - ::Reorg\_TRT version 1  
[TRT] Registered plugin creator - ::Region\_TRT version 1  
[TRT] Registered plugin creator - ::Clip\_TRT version 1  
[TRT] Registered plugin creator - ::LReLU\_TRT version 1  
[TRT] Registered plugin creator - ::PriorBox\_TRT version 1  
[TRT] Registered plugin creator - ::Normalize\_TRT version 1  
[TRT] Registered plugin creator - ::ScatterND version 1  
[TRT] Registered plugin creator - ::RPROI\_TRT version 1  
[TRT] Registered plugin creator - ::BatchedNMS\_TRT version 1  
[TRT] Registered plugin creator - ::BatchedNMSDynamic\_TRT version 1  
[TRT] Could not register plugin creator - ::FlattenConcat\_TRT version 1  
[TRT] Registered plugin creator - ::CropAndResize version 1  
[TRT] Registered plugin creator - ::DetectionLayer\_TRT version 1  
[TRT] Registered plugin creator - ::EfficientNMS\_ONNX\_TRT version 1  
[TRT] Registered plugin creator - ::EfficientNMS\_TRT version 1  
[TRT] Registered plugin creator - ::Proposal version 1  
[TRT] Registered plugin creator - ::ProposalLayer\_TRT version 1  
[TRT] Registered plugin creator - ::PyramidROIAlign\_TRT version 1  
[TRT] Registered plugin creator - ::ResizeNearest\_TRT version 1  
[TRT] Registered plugin creator - ::Split version 1  
[TRT] Registered plugin creator - ::SpecialSlice\_TRT version 1  
[TRT] Registered plugin creator - ::InstanceNormalization\_TRT version 1  
[TRT] detected model format - ONNX (extension ‘.onnx’)  
[TRT] desired precision specified for GPU: FASTEST  
[TRT] requested fasted precision for device GPU without providing valid calibrator, disabling INT8  
[TRT] [MemUsageChange] Init CUDA: CPU +203, GPU +0, now: CPU 234, GPU 3874 (MiB)  
[TRT] native precisions detected for GPU: FP32, FP16  
[TRT] selecting fastest native precision for GPU: FP16  
[TRT] attempting to open engine cache file .1.1.8001.GPU.FP16.engine  
[TRT] cache file not found, profiling network model on device GPU

error: model file ’ /home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx’ was not found.  
if loading a built-in model, maybe it wasn’t downloaded before.

Run the Model Downloader tool again and select it for download:

$ cd /tools  
$ ./download-models.sh

[TRT] failed to load /home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx  
[TRT] imageNet – failed to initialize.  
jetson.inference – imageNet failed to load built-in network ‘alexnet’  
Traceback (most recent call last):  
File “/home/jetson/Desktop/pyPro/NVIDIA/deepLearning-10.py”, line 17, in   
net=jetson.inference.imageNet(‘alexnet’,[‘–model= /home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx’,‘–input\_blob=input\_0’,‘–output\_blob=output\_0’,‘–labels= /home/jetson/Downloads/jetson-inference/myTrain/labels.txt’])  
Exception: jetson.inference – imageNet failed to load network

jetson@jetson-desktop:~/Desktop/pyPro$

I have checked the path many times to see if I have it right. It looks good. I am just trying to recognize one model. It seemed to train ok. The conversion from Pytorch to onnx\_export.py seemed to run good.  
I am running Pytorch 1.10.0  
L4t 32.6.1  
TensorRT: 8.0.1.6

I hope that I have given you enough information to go on.

Thank you for your time & help,  
Brent

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [December 20, 2021, 4:34pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/15 "2021-12-20T16:34:14Z")

</div>

> [@my65gto2](#):
>
> `error: model file ’ /home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx’ was not found`  
> I have checked the path many times to see if I have it right. It looks good.

Hi @my65gto2, the error reports that it can’t find this file, so I recommend to double/triple-check the path to make sure that it’s correct. What happens if you do:

```bash
ls -ll /home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx

```

---

<div class="post-metadata">

**Author:** ![my65gto2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@my65gto2](https://forums.developer.nvidia.com/u/my65gto2)\
**Post date:** [December 20, 2021, 8:02pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/17 "2021-12-20T20:02:05Z")

</div>

This is what I get:

jetson@jetson-desktop:/$ ls -ll /home/jetson/Downloads/jetson-inference/python/training/classification/myModel  
total 218528  
-rw-rw-r-- 1 jetson jetson 89513359 Dec 16 21:56 checkpoint.pth.tar  
-rw-rw-r-- 1 jetson jetson 89513359 Dec 16 21:50 model\_best.pth.tar  
-rw-rw-r-- 1 jetson jetson 44744191 Dec 17 11:05 resnet18.onnx

Brent

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [December 20, 2021, 8:19pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/18 "2021-12-20T20:19:50Z")

</div>

I think I just noticed a couple extra spaces in your arguments:

`[’–model= /home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx’,’–input_blob=input_0’,’–output_blob=output_0’,’–labels= /home/jetson/Downloads/jetson-inference/myTrain/labels.txt’]`

(in between `--model=` and the path, and also `--labels` and the path)

Can you try it with this instead:

`['--model=/home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx','--input_blob=input_0', '--output_blob=output_0', '--labels=/home/jetson/Downloads/jetson-inference/myTrain/labels.txt']`

If that doesn’t work, can you try seeing if the imagenet program can load it like so:

```auto
imagenet --model=/home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx --input_blob=input_0 --output_blob=output_0 --labels=/home/jetson/Downloads/jetson-inference/myTrain/labels.txt images/cat_0.jpg

```

---

<div class="post-metadata">

**Author:** ![my65gto2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@my65gto2](https://forums.developer.nvidia.com/u/my65gto2)\
**Post date:** [December 20, 2021, 8:57pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/19 "2021-12-20T20:57:21Z")

</div>

You know Dusty, sometimes these problems are like a needle in a haystack. I misspelled classification. Thank you for all of your time and help! I am trying to program and build a pick and place robot, any direction that you might have me check out?

Thanks again,  
Merry Christmas,  
Brent

> ![](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/45/14043_2.png "dusty\_nv") | [dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv) Moderator  
> December 20 |
> 
> - | - |

I think I just noticed a couple extra spaces in your arguments:

`[’–model= /home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx’,’–input_blob=input_0’,’–output_blob=output_0’,’–labels= /home/jetson/Downloads/jetson-inference/myTrain/labels.txt’]`

(in between `--model=` and the path, and also `--labels` and the path)

Can you try it with this instead:

`['--model=/home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx','--input_blob=input_0', '--output_blob=output_0', '--labels=/home/jetson/Downloads/jetson-inference/myTrain/labels.txt']`

If that doesn’t work, can you try seeing if the imagenet program can load it like so:

```auto
imagenet --model=/home/jetson/Downloads/jetson-inference/python/training/classfication/myModel/resnet18.onnx --input_blob=input_0 --output_blob=output_0 --labels=/home/jetson/Downloads/jetson-inference/myTrain/labels.txt images/cat_0.jpg

```

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [December 21, 2021, 3:26pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/20 "2021-12-21T15:26:51Z")

</div>

> [@my65gto2](#):
>
> You know Dusty, sometimes these problems are like a needle in a haystack. I misspelled classification.

Ah sorry, I had missed that too! Glad that you got it working :)

> [@my65gto2](#):
>
> I am trying to program and build a pick and place robot, any direction that you might have me check out?

I recall there being some robotic arms on the Jetson Projects page - you might want to check these links out:

- [Jetson Community Projects | NVIDIA Developer](https://developer.nvidia.com/embedded/community/jetson-projects)
- [JetMax AI vision robotic arm powered by Jetson Nano - Hackster.io](https://www.hackster.io/hiwonder-technology/jetmax-ai-vision-robotic-arm-powered-by-jetson-nano-62b1f6)
- [6DOF AI Visual Robotic Arm ROS Educational Robot for JETSON NANO 4GB](https://category.yahboom.net/products/dofbot-jetson_nano)

---

<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:** [January 4, 2022, 3:27pm UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/21 "2022-01-04T15:27:26Z")

</div>

Closed on January 4, 2022, 3:27pm UTC

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

---

<div class="post-metadata">

**Author:** ![kayccc](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kayccc/32/14043_2.png) [@kayccc](https://forums.developer.nvidia.com/u/kayccc)\
**Post date:** [January 12, 2022, 1:21am UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/22 "2022-01-12T01:21:56Z")

</div>

Opened on January 12, 2022, 1:21am UTC



---

<div class="post-metadata">

**Author:** ![kayccc](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kayccc/32/14043_2.png) [@kayccc](https://forums.developer.nvidia.com/u/kayccc)\
**Post date:** [January 12, 2022, 1:22am UTC](https://forums.developer.nvidia.com/t/problems-training-models/196989/24 "2022-01-12T01:22:12Z")

</div>

Closed on January 12, 2022, 1:22am UTC


