RTX4090 issue with pytorch

John_Doe2: <p>Hi there, i have a new rtx4090 that works for anything else. but for pytorch it is as slow as my old gtx1070. the comparison is weird, because it should be many times faster. but they run same test script in more or less same time. also, the 4090 is on a clean new machine.<br>
i have tries different cuda / pytorch versions. nothing speeds it up.<br>
any tips how i can get the 4090 to work with pytorch?<br>
is on windows</p>

ptrblck: <p>Did you profile your workload to check where the bottleneck is? E.g. are both GPUs running into a data loading bottleneck and the faster compute won’t help as it wasn’t slowing down your old system?</p>

John_Doe2: <p>I am using a small dataset to run the test. it is 70000 lines with 7 columns as features. the loss and predictions / gradients show it is iterating as expected on both machines. but the speed is weirdly same / faster on old machine.<br>
not sure what other workload check i can do? it seems on surface there is some installation issue. although i installed same pytorch on visual studio on both machines. i also installed cuda directly from nvidia, but i think that was not even required.</p>

ptrblck: <p>Why do you think it’s an installation issue and did you profile the code using e.g. Nsight Systems?<br>
I wouldn’t speculate but just check the timelines to see where the bottleneck is.</p>

John_Doe2: <aside class="quote no-group" data-username="ptrblck" data-post="4" data-topic="188653">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p>Nsight Systems</p>
</blockquote>
</aside>
<p>thanks. i never used that one. will read and try.<br>
reason i think is installation issue is because the hardware difference between the two machines is so big; it cant be they have same speed. old one is i5 with gtx1070 and new one is i9 with rtx4090. any other code or data manipulation is much faster on the new machine. but you are right, maybe speed of gpu was not a problem from the beginning.</p>

John_Doe2: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/f/d/fdfcaf15659bcebb7c1f27819f192a379351137e.png" data-download-href="https://discuss.pytorch.org/uploads/default/fdfcaf15659bcebb7c1f27819f192a379351137e" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/f/d/fdfcaf15659bcebb7c1f27819f192a379351137e_2_690x226.png" alt="image" data-base62-sha1="AeSaIlgbEL9YJ2FhCUmB3iPtX9s" width="690" height="226" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/f/d/fdfcaf15659bcebb7c1f27819f192a379351137e_2_690x226.png, https://discuss.pytorch.org/uploads/default/optimized/3X/f/d/fdfcaf15659bcebb7c1f27819f192a379351137e_2_1035x339.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/f/d/fdfcaf15659bcebb7c1f27819f192a379351137e_2_1380x452.png 2x" data-dominant-color="396663"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1390×456 23.2 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
so this is how it looks when i run a report on it. not having any Nsight experience is not helping… can you see any issue here maybe? thanks for the help.</p>

John_Doe2: <p>sorry to reply to my thread. i see in troubleshooting forum some people suggest installing CUDNN. however, my old machine did not have that installed. could that be needed for 4090?</p>

ptrblck: <p>The PyTorch binaries already ship with cuDNN and your locally installed CUDA toolkit (and cuDNN) won’t be used unless you build PyTorch from source.<br>
Could you annotate your script as described <a href="https://dev-discuss.pytorch.org/t/using-nsight-systems-to-profile-gpu-workload/59">here</a> and check the iteration time between your new and old machine?</p>

John_Doe2: <p>thanks for taking the time. i tried implement that code, but not knowing how nsight works and interpreting anything out of it makes it too time consuming. i was thinking maybe someone else experienced same performance issue with rtx4090. if anyone knows a reason that this hardware not perform as it should, please post in this thread.<br>
i will try test on tensorflow and see if the speed is better.</p>

John_Doe2: <p>so, i tried testing with tensorflow. apparently tensorflow stopped supporting windows…<br>
so it reverted to using cpu… not a real test <img src="https://discuss.pytorch.org/images/emoji/apple/frowning.png?v=12" title=":frowning:" class="emoji" alt=":frowning:" loading="lazy" width="20" height="20"><br>
if anyone has tips on what the root cause can be in installation / code please throw any ideas</p>

srinath: <p>hey,<br>
Our group is also using a few RTX 4090, and they are working pretty well as of now, and no one has had any problems with performance. Maybe the dataset is too small to see performance differences in your case. I would recommend benchmarking with slightly large datasets.</p>

John_Doe2: <p>hey there!<br>
Thanks, indeed one of the problems was the dataset size.<br>
But in setup i made a mistake: I was using the pycharm built-in python interpreter that did not have the path variable correctly set. also XFORMERS_AVAILABLE was True and system / graphics/hardware acceleration for gpu was on.<br>
i installed a clean python with the path set. this already improved the speed. and set xformers false., hardware acc = off.<br>
then i increased batch size.<br>
also increased sequence size to test.<br>
in the end, with these changes rtx 4090 is 5x faster than the gtx1070.<br>
of course i will not keep batch and sequence fixed.</p>
<p>but conclusion: pytorch does work with rtx4090. you just need not be an idiot like me <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>

ptrblck: <p>Thanks for the update and I wouldn’t be to harsh on yourself, as indeed interpreting performance profiles might not be trivial.<br>
I’m still unsure how the Python interpreter was related to the issue, but in any case it’s good to hear you are seeing the expected speedup now.</p>

LogicPy: <p>It’s indeed odd that your RTX 4090 is performing similarly to the GTX 1070, especially given the expected significant hardware improvements. Here are a few troubleshooting steps to consider:</p>
<ol>
<li>
<p><strong>Check CUDA Compatibility</strong>:</p>
<ul>
<li>Ensure you’ve installed the latest NVIDIA drivers compatible with your GPU.</li>
<li>Verify that the CUDA toolkit version you’ve installed is compatible with the PyTorch version you’re using. You can consult the <a href="https://pytorch.org/get-started/locally/" rel="noopener nofollow ugc">PyTorch website</a> to see the recommended CUDA version for each PyTorch release.</li>
</ul>
</li>
<li>
<p><strong>Utilization Check</strong>:</p>
<ul>
<li>Monitor the GPU utilization using NVIDIA’s System Management Interface (<code>nvidia-smi</code>) while running your PyTorch script. This will let you see if PyTorch is indeed using the RTX 4090. A low utilization might indicate that the GPU isn’t being fully engaged.</li>
</ul>
</li>
<li>
<p><strong>Memory Bandwidth</strong>:</p>
<ul>
<li>The performance might be bottlenecked by memory bandwidth, especially if your model is large. You can check the memory usage also via <code>nvidia-smi</code>.</li>
</ul>
</li>
<li>
<p><strong>Tensor Cores</strong>:</p>
<ul>
<li>The newer GPUs like the RTX 4090 have specialized Tensor Cores which can dramatically speed up certain operations. Ensure your model and operations are optimized to take advantage of these. For example, using <code>float16</code> (or “half precision”) can leverage Tensor Cores more effectively.</li>
</ul>
</li>
<li>
<p><strong>Framework Configuration</strong>:</p>
<ul>
<li>Check if PyTorch is running in CUDA mode: <code>print(torch.cuda.is_available())</code> should return <code>True</code>.</li>
<li>Explicitly move your model and data to the CUDA device in your script using <code>.cuda()</code> or <code>.to('cuda:0')</code>.</li>
</ul>
</li>
<li>
<p><strong>External Factors</strong>:</p>
<ul>
<li>Ensure there aren’t other processes that heavily utilize the GPU while you’re running your PyTorch script.</li>
<li>On Windows, ensure that the GPU is set to “Maximum Performance” in the NVIDIA Control Panel.</li>
</ul>
</li>
<li>
<p><strong>Test Script</strong>:</p>
<ul>
<li>If possible, run a benchmark script or a standard model like ResNet to compare the performance between the two GPUs. This helps in isolating if the problem is with your specific script or the setup in general.</li>
</ul>
</li>
<li>
<p><strong>Software Conflicts</strong>:</p>
<ul>
<li>Since you mentioned the RTX 4090 is on a new clean machine, ensure there aren’t any conflicting software or drivers. Sometimes, having multiple versions of CUDA or cuDNN can cause issues.</li>
</ul>
</li>
</ol>
<p>If after trying these steps you’re still facing the same issue, it could be a more intricate problem that might need deeper investigation.</p>

ptrblck: <aside class="quote no-group" data-username="LogicPy" data-post="14" data-topic="188653">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/logicpy/48/60452_2.png" class="avatar"> LogicPy:</div>
<blockquote>
<p>It’s indeed odd that your RTX 4090 is performing similarly to the GTX 1070, especially given the expected significant hardware improvements.</p>
</blockquote>
</aside>
<p>It doesn’t as was already clarified. Did you read the topic or is this a ChatGPT generated post?</p>

LogicPy: <p>Yeah, I’m sorry. I didn’t read the replies. And it’s true most of my response was generated by GPT-4. I was just trying to help. Sorry, friends. <img src="https://discuss.pytorch.org/images/emoji/apple/neutral_face.png?v=12" title=":neutral_face:" class="emoji" alt=":neutral_face:" loading="lazy" width="20" height="20"></p>
<p>I’ll read more next time. I just instinctively thought the thread was new due to receiving an email about it just this morning. Sorry again though…</p>

Sergii_Makarevych: <p>I am having a different kind of issue but with RTX4090 on ProArt Z790-CREATOR WIFI with Intel(R) Core™ i9-14900KF and pytorch.</p>
<pre><code class="lang-auto">lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 23.10
Release:	23.10
Codename:	mantic
</code></pre>
<pre><code class="lang-auto">pip freeze
filelock==3.13.3
fsspec==2024.3.1
Jinja2==3.1.3
MarkupSafe==2.1.5
mpmath==1.3.0
networkx==3.2.1
numpy==1.26.4
nvidia-cublas-cu12==12.1.3.1
nvidia-cuda-cupti-cu12==12.1.105
nvidia-cuda-nvrtc-cu12==12.1.105
nvidia-cuda-runtime-cu12==12.1.105
nvidia-cudnn-cu12==8.9.2.26
nvidia-cufft-cu12==11.0.2.54
nvidia-curand-cu12==10.3.2.106
nvidia-cusolver-cu12==11.4.5.107
nvidia-cusparse-cu12==12.1.0.106
nvidia-nccl-cu12==2.19.3
nvidia-nvjitlink-cu12==12.4.127
nvidia-nvtx-cu12==12.1.105
pillow==10.3.0
sympy==1.12
torch==2.2.2
torchvision==0.17.2
triton==2.2.0
typing_extensions==4.10.0
</code></pre>
<pre><code class="lang-auto">nvidia driver version 535 / 545/ 550
</code></pre>
<p>code - official mnist examples <a href="https://github.com/pytorch/examples/blob/main/mnist/main.py" class="inline-onebox" rel="noopener nofollow ugc">examples/mnist/main.py at main · pytorch/examples · GitHub</a></p>
<p>error I get in /var/log/kern.log:</p>
<pre><code class="lang-auto">kernel tried to execute NX-protected page - exploit attempt? 
</code></pre>
<p>the error happens within few minutes of the training</p>
<p>I tried reinstalling the whole system from scratch few times. upgraded BIOS, three different driver versions. nothing helped.</p>
<p>any suggestion what direction to dig ? Maybe <a class="mention" href="/u/ptrblck">@ptrblck</a> ? Thank you.</p>