Multiple anaconda environments for different Pytorch versions

username: eastchun
cooked: <p>I have installed CUDA 11.3.1 with cudnn 8.2.1 in my Windows 10 desktop PC.<br>
I have an anaconda environment with pytorch 1.12.1, CUDAtoolkit 11.3.1, cudnn 8.2.1, python 3.7.<br>
I want to create another anaconda environment in order to install pytorch 1.4.0 (with python 3.6).</p>
<p>According to Pytorch website, pytorch 1.4.0 works with CUDA 10.1.<br>
So, I need to install CUDA 10.1 in my Windows desktop (in addition to the exsing CUDA 11.3.1).</p>
<p>Under this circumstance, I have the following questions:</p>
<ol>
<li>
<p>After installing another CUDA in my desktop, do I need to explicitely specify the system variables for this newly installed CUDA?  (I found that there are two system variables for the existing CUDA 11.3.1: “CUDA_PATH” and “CUDA_PATH_V10_13”).</p>
</li>
<li>
<p>Suppose I created a new anaconda environment with python 3.6.<br>
Then, in order to install pytorch 1.4.0, do I need to specify cudatoolkit version in the command?<br>
or Pytorch will automatically grab the appropriate CUDA (i.e., CUDA 10.1) in my desktop PC?</p>
<p>i.e.,<br>
conda install pytorch==1.4.0 torchvision==0.5.0 torchaudio cudatoolkit==10.1 -c pytorch<br>
vs.<br>
conda install pytorch==1.4.0 torchvision==0.5.0 torchaudio -c pytorch</p>
</li>
</ol>

username: ptrblck
cooked: <p>You don’t need to install a local CUDA toolkit to execute the PyTorch binaries as they ship with their own CUDA runtime, cuDNN, NCCL etc.</p>
<p>Yes, you should use the full install command including <code>cudatoolkit</code> if given.</p>

username: eastchun
cooked: <p>I missed the step in my anaconda to install an old cudatoolkit with a specific version that is specified in pytorch installation command (in my case cudatookit==10.1). Successfully installed the old version pytorch after installing this cudatookit in my anaconda. Thanks.</p>

username: eastchun
cooked: <p>BTW, whole mess came up due to “next(self.parameters()).device” in my old pytorch script in which is no longer supported in the recent pytorch.</p>

username: ptrblck
cooked: <p>I’m unsure what “mess” you mean as the code still works in the current nightly release:</p>
<pre><code class="lang-python">model = models.resnet101()
model.cuda()

next(model.parameters()).device
# device(type='cuda', index=0)
</code></pre>

username: eastchun
cooked: <p>Current nightly release in your reply means Pytorch 1.13.1??<br>
(Some of my packages do not support Python 3.9 or beyond).</p>
<p>With Pytorch (1.12.1) / Python (3.7.16), I got the following StopIteration error (No error for  Pytorch 1.4.0 with Python 3.6.9).</p>
<p>Traceback (most recent call last):<br>
File “synthesizer_train_kor_tv.py”, line 53, in <br>
train(**vars(args))<br>
File “C:\East\dreambyte\Deepfake\pyworks\RTVC_Korean\synthesizer\train_kor_tv.py”, line 321, in train<br>
data_parallel_workaround(model, texts, mels, embeds, val_cycle) # ./synthesizer/utils/<strong>init</strong>.py<br>
File “C:\East\dreambyte\Deepfake\pyworks\RTVC_Korean\synthesizer\utils_<em>init</em>_.py”, line 17, in data_parallel_workaround<br>
outputs = torch.nn.parallel.parallel_apply(replicas, inputs)<br>
File “C:\Users\East.conda\envs\ml_gpu\lib\site-packages\torch\nn\parallel\parallel_apply.py”, line 86, in parallel_apply<br>
output.reraise()<br>
File “C:\Users\East.conda\envs\ml_gpu\lib\site-packages\torch_utils.py”, line 461, in reraise<br>
raise exception<br>
StopIteration: Caught StopIteration in replica 0 on device 0.<br>
Original Traceback (most recent call last):<br>
File “C:\Users\East.conda\envs\ml_gpu\lib\site-packages\torch\nn\parallel\parallel_apply.py”, line 61, in _worker<br>
output = module(*input, **kwargs)<br>
File “C:\Users\East.conda\envs\ml_gpu\lib\site-packages\torch\nn\modules\module.py”, line 1130, in _call_impl<br>
return forward_call(*input, **kwargs)<br>
File “C:\East\dreambyte\Deepfake\pyworks\RTVC_Korean\synthesizer\models\tacotron.py”, line 491, in forward<br>
<strong>device = next(self.parameters()).device</strong>  # use same device as parameters<br>
StopIteration</p>