Using WSL Linux on Windows 10 for Deep Learning Development. – Source Erogol.com
To explain briefly, WSL enables you to run Linux on Win10 and you can use your favorite Linux tools (bash, zsh, vim) for your development cycle and you can enjoy Win10 for the rest. It obviates the need for dual-boot configuration which might be a nightmare sometimes.
Why I do this? Basically, if you have an Optimus Laptop, it is an onerous job to set up a Linux distro. You need to find the right Nvidia driver to enable GPU. Then you need to install nvidia-prime or if you are lucky, you make bumblebee work. Let’s say you’ve done everything. After some time, you update something on your system by mistake and the next thing you see a black screen for the next reboot. It is time to search what is wrong on your phone and try to fix it. It is horrendous!
As far as my experience goes, WSL Linux gives all the necessary features for your development with a vital exception of reaching to GPU. You can apt-get software, run it. Even you can run a software with UI if you set things right. However, due to the GPU limitation, you are able to compile CUDA codes but cannot run on Linux. Here I just like to explain, how you can deal with limitation with a small trick using the ability of WSL Linux running Win binaries.
The first thing to do is to install your preferred Linux distro from Windows Store. Just go to the store, search for the distro and install. If installation is not available, you might need to update your Windows.
1. Install Linux and activate WSL
Before launching Linux, follow the documnetation here to activate WSL on Win10.
After you installed the distro and activated WSL, you can either open the command-line and type “`bash“` or directly use the Linux launcher to get into the linux terminal.
2. Install Hyper Terminal for Linux like experience.
One problem I’ve experienced with Windows command-line is the differences of shortcuts (Copy-Paste) and inability to open multiple tabs. These are quite important features for Linux custom. I solved this by switching to hyper terminal. It simulates the best possible Linux like experience.
3. Install Conda in Windows and add its binaries to `path`
Now you have Linux and a cool terminal. It is time to install the rest. Note that, if you don’t bother to use GPU, you can install everything you like on Linux right away and use. For this example, we install miniconda to Windows and use the python.exe from Linux to run our codes on GPU.
Another cool thing about Linux on WSL is that it enables you to run Windows binaries on Linux environment. Also, Windows’ PATH environment variable is exposed to Linux too. As we install python with miniconda, it asks you to add python.exe to the PATH variable. Just do it. Then we set an alias on the Linux side to run python.exe, when we type python so that we can develop things on Linux but run the code on Windows by using the GPU.
Now install miniconda. Say next until you see the screen below and set the ticks for the all options.
After the installation, if you run python on command-line you should see python session running as shown below.
You should also be able to run python form Linux. Open the terminal, switch Linux, type python.exe and you get it working.
4. Create aliases on Linux
The last step is to creating an alias on Linux bash that runs python.exe when you call python. These are the aliases I set.
alias conda="conda.exe" alias ipython="ipython.exe" alias nosetests="nosetests.exe" alias pip="pip.exe"
After all, you should be able to run your code on GPU. One important note is that since we use python on windows, you need to set folder paths in relation to Windows. Don’t forget the escape character for separating folder.
Right now, I created a folder /users/erogol/projects and I keep my development craft in it. So it is actually different from the home folder set for your Linux installation. But it does not matter since we use windows file paths. Now, you can install your favorite editor and enjoy training new models.
Please let me know if I skip something here. It is very likely since I wrote this after I set everything.
It is good too see that Microsoft changed direction and start to embrance Linux into their ecosystem by listening the needs of their users. It was a meaningless fight from the start.
The post Using WSL Linux on Windows 10 for Deep Learning Development. appeared first on A Blog From Human-engineer-being.