Windows 10 Installation Notes (Windows command and WSL bash)

Actually what happened was that after the installation it had removed

activate.bat
activate
deactivate.bat
deactivate

from the Scripts Directory…
Except that As far as i have used it ,
It just works fine till now…

Oh well, that’s not too bad - so far I have seen these as used to link Keras to either Theano or Tensorflow, but in any case it should all be well documented in articles on the internet!

In case anyone gets stuck on having OpenCV working, with messages like this

ModuleNotFoundError: No module named 'cv2'

or like this

ImportError: libSM.so.6: cannot open shared object file: No such file or directory

I am adding here advice I got from another post, that you may have to update some dependencies:

sudo apt-get install libsm6 libxrender1 libfontconfig1

And I am not sure if relevant since this post is about setting up your own installation, especially relevant to WIndows 10 setup, but advice from another user is to use the provided fastai environment - it’s not clear from the instructions here about how to work with the fastai environment…

conda env create -f environment.yml
1 Like

Seems that the original post can no longer be edited (60 day limit?). I’ve attached a pdf of a run of Lesson 1 to show that Windows + GPU is working. There’s some issues towards the end but they’re the same issues reported on non-Windows systems.fastai Lesson 1 Jupyter Notebook.pdf (2.4 MB)

As of this time, I see no Windows specific issues, at least not with Lesson 1.

1 Like

Hi Robert

I am getting the following error when I call learn.fit.

Did you make a change to the fastai library to overcome this (I updated to the latest version befoire running this today)?

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-38-688cebf597d5> in <module>()
----> 1 learn.fit(0.01, 3)

D:\FASTAI\fastai\fastai\learner.py in fit(self, lrs, n_cycle, wds, **kwargs)
    211         self.sched = None
    212         layer_opt = self.get_layer_opt(lrs, wds)
--> 213         self.fit_gen(self.model, self.data, layer_opt, n_cycle, **kwargs)
    214 
    215     def lr_find(self, start_lr=1e-5, end_lr=10, wds=None):

D:\FASTAI\fastai\fastai\learner.py in fit_gen(self, model, data, layer_opt, n_cycle, cycle_len, cycle_mult, cycle_save_name, metrics, callbacks, use_wd_sched, norm_wds, wds_sched_mult, **kwargs)
    158         n_epoch = sum_geom(cycle_len if cycle_len else 1, cycle_mult, n_cycle)
    159         fit(model, data, n_epoch, layer_opt.opt, self.crit,
--> 160             metrics=metrics, callbacks=callbacks, reg_fn=self.reg_fn, clip=self.clip, **kwargs)
    161 
    162     def get_layer_groups(self): return self.models.get_layer_groups()

D:\FASTAI\fastai\fastai\model.py in fit(model, data, epochs, opt, crit, metrics, callbacks, **kwargs)
     84             batch_num += 1
     85             for cb in callbacks: cb.on_batch_begin()
---> 86             loss = stepper.step(V(x),V(y))
     87             avg_loss = avg_loss * avg_mom + loss * (1-avg_mom)
     88             debias_loss = avg_loss / (1 - avg_mom**batch_num)

D:\FASTAI\fastai\fastai\model.py in step(self, xs, y)
     41         if isinstance(output,(tuple,list)): output,*xtra = output
     42         self.opt.zero_grad()
---> 43         loss = raw_loss = self.crit(output, y)
     44         if self.reg_fn: loss = self.reg_fn(output, xtra, raw_loss)
     45         loss.backward()

D:\Anaconda3\lib\site-packages\torch\nn\functional.py in nll_loss(input, target, weight, size_average, ignore_index, reduce)
   1047         weight = Variable(weight)
   1048     if dim == 2:
-> 1049         return torch._C._nn.nll_loss(input, target, weight, size_average, ignore_index, reduce)
   1050     elif dim == 4:
   1051         return torch._C._nn.nll_loss2d(input, target, weight, size_average, ignore_index, reduce)

RuntimeError: Expected object of type Variable[torch.cuda.LongTensor] but found type Variable[torch.cuda.IntTensor] for argument #1 'target'​

@Chris_Palmer, I have a couple of patches for that issue. It’s possible that it’s unique to Windows for any of a variety of possible reasons. The patches will make lesson1 run until you hit universal Value error (probably fastai lib error). It appears to me that there’s more patches needed as the problematic pattern is elsewhere in model.cp file. I’m guessing this is an issue with Python because it’s lacks static typed checking. TypePython anyone? I’ll open an issue/PR (done -
https://github.com/fastai/fastai/issues/71) on fastai’s github for the patches.

In fastai/fastai-master/fastai/model.cp:

Original: loss = raw_loss = self.crit(output, y)
Fix: loss = raw_loss = self.crit(output, y.long()) # patch

Original: return preds, self.crit(preds,y)
Fix: return preds, self.crit(preds,y.long()) # patch

After applying the patches, if you see this error “ValueError: Found input variables with inconsistent numbers of samples: [2000, 5]” you’ve reached the same error as other platforms (https://github.com/fastai/fastai/issues/70). Move on to something else until fastai fixes it.

3 Likes

Thanks Robert!

@Chris_Palmer, Per @jeremy’s advice, I’ve changed the above patches to use y.long() so they’ll work with both cpu and gpu processing.

1 Like

Thanks Robert, again :smiley:

1 Like

The latest fixes on fastai’s github allow lesson1 to complete without error. Previously lesson1 would error out at the 80% mark. True for all platforms.

git clone https://github.com/fastai/fastai

Windows users will need to slightly modify the lesson1 file. The difference being the replacement of non-portable bash shell commands with cross-platform python code. I’ve attached a pdf of a run of lesson1 on Windows + GPU which shows the replacements for the bash commands. – No I haven’t. The file is too large. I’ll have to post some other way.

pytorch for Windows has been updated to use CUDA 9.0. tensorflow-gpu still requires CUDA 8.0. I’ve installed CUDA 8 and CUDA 9 side-by-side without problem. I can now use CUDA 9 with pytorch and CUDA 8 with tensorflow-gpu.

conda install -c peterjc123 pytorch cuda90

The next version of pytorch, version 0.40, is suppose to officially support Windows.

1 Like

I’ve just pushed the change to add long() when calling self.crit. Let me know if you see any problems.

I reran Lesson1 on Windows-gpu. It completed without errors. Thanks for committing the changes.

N.B. I use these commands to update changes at https://github.com/fastai/fastai master. The commands will update changes from master without deleting files not tracked by git (e.g. courses/dl1/data). Important: If you have any local changes that are tracked by git, they will be lost. With or without --hard option, any local commits that haven’t been pushed will be lost.

git fetch --all
git reset --hard origin/master

Good Stackoverflow discussion of git commands for updating. Many alternatives commands are suggested. Depends on your git situation.

How do I force git pull to overwrite local files?

1 Like

Tensorflow 1.5 rc is now available for Windows GPU. It uses CUDA 9.0. The release version, perhaps Feb 1st, will support CUDA 9.1 (current).

Well, I didn’t see this thread before… so I wrote (kind of again) a description on how I got the library working with GPU acceleration under Windows 10: https://github.com/cklukas/fastai/blob/master/doc/windows_setup.md

I needed to adjust a little of the notebook code, e.g. when listing directories, etc… Otherwise at least the first few notebooks worked very fine in my tests.

1 Like

@klukas Very nice writeup. I’ll try to find some time to merge this thread’s notes with your writeup.

I followed your instructions to make lesson1 work on my win10 machine(GTX1060) . But it is very slow.It takes about two hours to finish model run. It seems it uses CPU not GPU. Do I need more configuration to make it work on GPU?

Did you install the cuda and cudnn drivers from nvidia.com?

CUDA:

https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64

CUDNN:

I have CUDA 8.0 and CUDA 9.1 installed. I think I use CUDA 8 for Keras and 9.x for pytorch, but I am not 100% sure…

fastai needs a prerequisites validation test suite. People could run it to verify their installation including GPU compatibility. Here’s a one liner which displays GPU compatibility with Tensorflow. The output will show whether a GPU has been found or not. If your GPU isn’t mentioned, it’s not visible to Tensorflow.

python -c "import tensorflow as tf;sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))"

I did this but instead got this error:-


TypeError: eq received an invalid combination of arguments - got (torch.cuda.IntTensor), but expected one of:

  • (int value)
    didn’t match because some of the arguments have invalid types: (torch.cuda.IntTensor)
  • (torch.cuda.LongTensor other)
    didn’t match because some of the arguments have invalid types: (torch.cuda.IntTensor)