Setting up PyTorch environment w/Win10, Cuda

username: cdrouin
cooked: <p>Hi, all.  I’m trying to get PyTorch up and running locally on a Win10 laptop, and I’ve been having a fair bit of difficulty; everything crashes and burns when I hit a call to <code>torch._C._cuda_init()</code> with a rather unhelpful runtime error (<code>RuntimeError: CUDA error: unknown error</code>).  <code>torch.cuda.is_available()</code> returns true, and I am able to set the device to “cuda:0” .</p>
<p>Here’s how my laptop is currently set up:</p>
<ul>
<li>GPU: GeForce GTX 1050ti (Max-Q variant)</li>
<li>GPU driver version: 431.36</li>
<li>CUDA Version: 10.1 (I’ve installed the 10.0 archival version from nVidia’s site, but 10.1 shows up when I run nvidia-smi.  I did originally start with the 10.1 installer, but tried to uninstall all the components; is there something I need to do to get a clean uninstall?)</li>
<li>PyTorch + torchvision were installed via conda using <code>conda install pytorch torchvision cudatoolkit=10.0 -c pytorch</code> ; pytorch shows as version 1.1.0 with build <code>py3.7_cuda100_cudnn7_1</code> .</li>
</ul>
<p>I tried uninstalling my drivers entirely and just installing the CUDA 10.0 toolkit, but on doing so nvidia-smi reported that it couldn’t communicate with drivers.  Do I need to try to roll back to an earlier GPU driver version?  Is there something in particular I need to do to go vestiges of the CUDA 10.1 toolkit off of my machine?  Should I take off and nuke it all from orbit?</p>

username: ptrblck
cooked: <p>Could you try to install the latest pytorch nightly build as suggested in <a href="https://github.com/pytorch/pytorch/issues/17108" rel="nofollow noopener">this issue</a>?<br>
Let us know, if that doesn’t help and you still get this error.</p>

username: cdrouin
cooked: <p>Hm.  I uninstalled the stable version and installed the nightly, but now things appear to be broken further.  The torch module seems to be mostly empty when I inspect it with <code>help('torch')</code>, showing only the submodules nn and utils - no <code>cuda</code>, which means that the second we hit a <code>torch.cuda</code> reference it falls over.</p>
<p>If it helps, I installed torch-nightly via <code>conda install pytorch-nightly cudatoolkit=10.0 -c pytorch</code> , and it installed <code>pytorch/win-64::pytorch-nightly-1.2.0.dev20190714-py3.7_cuda100_cudnn7_0</code>.</p>
<p>Having said that, the nightly that was mentioned as working in that thread is from February.  I’m going to see if I can pull an older version of pytorch (either one of the older nightlies or 1.0.0, which was mentioned to be working in that thread) and see where that takes me.</p>
<p>edit: It’s a hack, but making a call to <code>torch.cuda.current_device()</code> (as mentioned in that thread) appears to resolve this issue.</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="cdrouin" data-post="3" data-topic="50597">
<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/cdrouin/48/14076_2.png" class="avatar"> cdrouin:</div>
<blockquote>
<p>It’s a hack, but making a call to <code>torch.cuda.current_device()</code> (as mentioned in that thread) appears to resolve this issue.</p>
</blockquote>
</aside>
<p>Without this line of code you cannot call any CUDA functions without raising an error?</p>
<p>CC <a class="mention" href="/u/peterjc123">@peterjc123</a>: could this be related to the linked issue (which should have been resolved)?</p>

username: peterjc123
cooked: <p>I don’t think an incomplete python package will get uploaded. We will run some basic smoke tests before uploading these packages. Apparently, importing <code>torch.cuda</code> is one of them. Also, from the size of the package, it is normal, which is around ~500MB. However, I’ll check it later. As for the problem, have you completely removed the old installation? What if you do <code>conda uninstall pytorch</code>, <code>pip uninstall torch</code>, <code>conda uninstall pytorch-nightly</code> and <code>pip uninstall torch-nightly</code> in a row and then install it again? Also, would you please check if there is any pytorch installation in your <code>PYTHONPATH</code>?</p>

username: cdrouin
cooked: <p>I was able to call <code>torch.cuda.is_available()</code> and <code>torch.device()</code> (not strictly a CUDA function, I think, but was using it to set the device to “cuda:0”) without anything blowing up.</p>
<p><a class="mention" href="/u/peterjc123">@peterjc123</a> , I’d uninstalled pytorch + torchvision + pytorch-nightly before attempting the (re)install operation.  Note that I’m using conda, not pip, in case that has anything to do with the issue.  To get torchvision (re)installed on top of pytorch-nightly, I had to use the <code>--no-deps</code> flag since it otherwise requires pytorch to be install.</p>
<p>It appears I don’t actually have a <code>PYTHONPATH</code> environment variable on this system (FWIW - installed using the Anaconda graphical installer); I don’t see pytorch referenced in the normal <code>PATH</code> variable either.</p>

username: peterjc123
cooked: <p>Yes, I know. I just want to ensure torch is uninstalled. Using <code>pip uninstall</code> is harmless since it will ask for your confirmation. If you ensure the package is completely removed, then it is likely that the package you downloaded is incomplete or broken. Please remove the cache file in <code>[Anaconda Root]\pkgs</code> and try again. Alternatively, you can download the file from <a href="https://anaconda.org/pytorch/pytorch-nightly/files" rel="nofollow noopener">https://anaconda.org/pytorch/pytorch-nightly/files</a> and install it locally.</p>