If you can get a spare SSD even a $95 Samsung EVO 250GB you can install it there and it is really easy. Recommend unplugging windows drive during the install to make things easier. You can do two things from there. Setup grub (boot loader) to configure for windows or just use bios boot selection (typically f8,f11,f12 on boot) to select which drive to boot.
Thanks again! I can’t afford getting a new SSD, I have already a SSD running W10 and a HDD for data, so my idea is to either make some space in the SSD for Ubuntu (but that would be tight, I don’t have much free space) or make a separate partition in the data HDD and then install Ubuntu there. In either case I’d like to set up a dual-boot with W10 booting by default.
Install the CUDA (https://developer.nvidia.com/cuda-downloads and http://developer.download.nvidia.com/compute/cuda/8.0/secure/Prod2/docs/sidebar/CUDA_Installation_Guide_Windows.pdf?autho=1490095075_48e6262b0ee4aeac8867553c5d25475a&file=CUDA_Installation_Guide_Windows.pdf).
Then install CuDNN (https://developer.nvidia.com/cudnn).
Install Anaconda on your machine…
Now you want to create a GPU environment for Tensorflow and install all these packages into it (and any other packages you want to use):
- conda create --name tensorflow-gpu python=3.5
- activate tensorflow-gpu
- conda install jupyter
- conda install scipy
- conda install matplotlib
- conda install pandas
- conda install scikit-learn
- conda install numpy
- conda install keras
- conda install pillow
- conda install bcolz
- conda install h5py
- pip install tensorflow-gpu
Note that you HAVE to use Anaconda Python 3.5… Tensorflow will only work with that specific version on Windows (not 2.7, not 3.6).
Whenever you want to use your new setup, pull up a Windows command prompt, and type this into it:
- activate tensorflow-gpu
Change to whatever directory you want, then ‘jupyter notebook’ to start up Jupyter. It will automatically open a browser window in your default browser.
A few things to note:
- Tensorflow uses different dimension ordering than Theano:
For 2D data (e.g. image), "tf" assumes (rows, cols, channels) while "th" assumes (channels, rows, cols). For 3D data, "tf" assumes (conv_dim1, conv_dim2, conv_dim3, channels) while "th" assumes (channels, conv_dim1, conv_dim2, conv_dim3).
- An alternate “quick and dirty” kludge for the class notebooks is to just specify “th” ordering in the keras.json file (in the .keras directory):
- There are a few things you need to change for Python 3.5 – such as cPickle becomes _Pickle… I don’t remember what they all were, but it something worked in 2.7 but you get an error in 3.5, that’s likely to be the problem.
I’m trying to remember if I missed anything… but this is basically what I did. I hope this helps!
One more thing I did forget… when specifying directories and files in the notebooks, you will have to use the Windows convention, not the linux, such as path = “data\\fish\” instead of path = “data/fish/”.
Thanks for your explanation, I’ll have to see which is the easier way to go for me
One thing that might make working with windows more palatable is the pathlib module in Python 3 - it reduces a lot of unnecessary text from os, os.path, glob, etc too.
from pathlib import Path basepath = Path('mypath') # overloads '/' operator train = basepath / 'train' # can create directories without raising an error if it already exists train.mkdir(parents=True, exist_ok=True) assert train.exists(), 'does not exist' assert train.is_dir(), 'not a directory' #recursively search for files matching a pattern file_gen = train.rglob('*.png') filepath = next(file_gen) #only issue is filepath is a Path object, not str #some modules know how to deal with that #others require str(filepath)
Thanks David, great point!
What an incredibly useful answer, Chris. Also a fan of your username spoonerism.
I believe you’re referring to the Nvidia NVLink technology here: http://www.nvidia.com/object/nvlink.html
But, as far as I can find, the tech seems to be for servers and workstations. Did not find any information about plans for a consumer version.
Yes, that’s it. I couldn’t find it quickly when I was on mobile. When I looked I couldn’t tell if it was going to be exclusive to their high end cards or not either. My guess it very well maybe. They already crippled the Titan X and 10xx cards for machine learning, so it is no surprise this would be held back from them as well.
I found it annoying to have to constantly restart my jupyter notebooks on my Ubuntu server. There are a bunch of ways to do this, but using systemd on Ubuntu you can set up an “always running” jupyter workplace (e.g. a directory with all your projects). Systemd will handle restarting for you after reboots or crashes.
Create the file: /etc/systemd/system/jupyter.service
[Unit] Description=Jupyter Workplace [Service] Type=simple PIDFile=/run/jupyter.pid ExecStart=/home/bfortuner/anaconda3/bin/jupyter-notebook --config=/home/bfortuner/.jupyter/jupyter_notebook_config.py User=bfortuner Group=bfortuner WorkingDirectory=/home/bfortuner/workplace Restart=always RestartSec=10 [Install] WantedBy=multi-user.target
Then, run the commands
systemctl enable jupyter.service systemctl daemon-reload systemctl restart jupyter.service
With this code then after a reboot jupyter notebook will just be running on the localhost:8888? And from a remote machine I would be able to use the code you gave to forward it with ssh to my laptop?
ssh -NL 8888:localhost:8888 user@host -p portnumber -i ~/.ssh/privatekey
This is awesome. Can’t wait to set it up! Thanks @brendan.
I’ve set up an Ubuntu 16.04 box and configured it for access from my mac laptop via ssh. Everything works well, except sleeping/suspending. After I suspend my box I can use a magic packet to wake it from my phone or laptop either on or off my home lan. But if I wait more than about 15 or 20 minutes neither works.
Has anybody gotten wake on lan to work consistently from outside their home network?
Or should I just leave my rig running 24/7?
I wrote up the steps for setting up a server in Ubuntu (Windows dual boot). For the complete Ubuntu/Windows ignoramus, like I am, or was.
Perhaps someone could add it to the Wiki Installation pages?
Setup Ubuntu local server, for beginners (including Windows dual boot)
This guide is geared toward beginners with Ubuntu and Windows, to get you set up for the course with minimal hassles. I will try to clearly lay out every step needed, without assuming that you already have prior skills with these OS’s.
I do assume that you are starting with a PC and an nVidia GPU. This guide is current as of 18-March-2017. The Ubuntu version installed is 16.04.2 LTS. For other Ubuntu versions and and hardware, YMMV.
Making the Ubuntu Installer
In this section, we create the Ubuntu installer on a flash drive, from Windows. If you are not starting from Windows, you will need to create the installer a different way. You will need a USB flash drive, 2 GB or larger.
To create the bootable installer drive, follow the instructions at
You will be installing Ubuntu in its own partition, separate from the Windows partition. You may find instructions that recommend using the Windows Disk Manager to pre-allocate a partition for Ubuntu. This is neither necessary nor advised. WDM is limited in how much it can shrink the Windows partition because there are system files that cannot be moved while Windows runs. The Ubuntu installer itself can do the partitioning better than WDM because Windows is not running and can be shrunk further. Just know your ideal partition sizes before proceeding.
The Ubuntu installer advises that an internet connection will speed up the installation. Actually, a bug in the installer will cause the installation to fail partway through when there is an internet connection. So disconnect internet during the install, and don’t waste time figuring this out.
Next, boot from the installer. This will likely require entering the BIOS screens to select the USB flash drive as the boot device.
The installer will let you choose “Install them side by side, choosing between them each startup” (for dual boot), and let you size the two partitions.
Once the installer finishes, remove the flash drive and boot from the hard drive. If all has gone well, you will see a menu that allows the choice between Ubuntu and Windows.
At the top of the Launcher is a search tile that allows you to find programs quickly. Terminal is one you will be using soon. Note that Ctrl-v does not work in Terminal. You have to right-click and select Paste from the menu.
The next tile below is the file browser with your Home directory as the root. At this point, go to Edit->Preferences->Views. Select “Show hidden and backup files”. You will need to edit some of these later.
System Settings (looks like a gear and wrench) gives access to many settings for personalizing Ubuntu. Be careful with the “Additional Drivers” tab. Ubuntu will offer to install a proprietary driver from nVidia. If you install it, you will be locked out of Ubuntu in a login screen loop. Instructions for escaping this situation are in the notes below.
Shutdown and reboot are found in the gear icon in the upper right corner.
Setting up the GPU and Course Material
Note: do NOT install the nVidia drivers offered in System Settings->Additional Drivers.
Fortunately, several generous experts have created a script that does the setup automatically. The script is found at
If you are easy with git, you can get the script file directly. Or click the Raw link, and using Text Editor simply copy/paste into a local file named install-GPU.sh.
Note that the script has recently been revised to install an older version of Keras, the one that the course’s code was designed for. Later you may want to update to the current Keras 2.
One small problem is that the script calls git, which is not yet installed. To install git, open a Terminal window and enter
sudo apt install git
Now it’s time to run the script. From the Terminal window, enter
(You may simply type "bash ", and drag the script file to Terminal to enter its path.)
Wait while the script runs.
As part of its operations, the script will install an up-to-date nVidia driver, one that does not have the boot loop problem. At some point, Ubuntu required me to enable Insecure Boot Mode and provided the steps. I do not recall when this occurred.
Open Terminal, and enter
If all has gone well, you will see the GPU and its state.
Running the Notebooks
A configuration change makes this more convenient. Open the .jupyter invisible folder found in Home, and edit jupyter_notebook_config.py. Edit the matching line to
c.NotebookApp.notebook_dir = u’courses/deeplearning1/nbs/’
This way jupyter will always open to the notebooks directory.
Next, enter in Terminal
To access the jupyter server, open a browser window and go to
You should see a file list that contains the lesson notebooks for the course. Open one of them and you are ready to work.
Inside a jupyter notebook, use shift-enter to run a cell.
To monitor GPU load, enter in a second Terminal,
Run Software Updater to get security updates that were not part of the installer.
To escape from the nVidia driver boot loop, at login type Ctrl + Alt + F1. At the login prompt, type your user name all lowercase, then your password. This is called TTY login.
sudo apt-get purge nvidia-*
- To browse root level, type in Terminal
Also, feel free to edit and correct.
On to Lesson 2!
So I just got my 1080 Ti and did a quick run on CatsDogs. First fit time was 190s vs 245 on my old 1080.
Good idea - and thanks! We’ll add it.
You should be able to do a lot better than that, I get 229s on a 1070 and when I calculated the cuda stats and terraflops I guestimated you can hit around 140s. I’m waiting for the Gamer X editions to come out with the proper cooling and higher stock clocks.
Thanks for the information I would like to add a fresh disk for linux I guess the dual boot would work in this situation. I have done this before a long long time ago (10+ years ago pre 64 bit) with mixed results, drivers for video cards etc.
If I get to the point of having my USB install then before installing linux install the additional hard drive then run the USB install would there be any issues you can think of. Or does windows 7 need to know about the drive
I let the Ubuntu installer re-partition the existing Windows drive. So I imagine the installer would have no trouble formatting and installing onto a separate drive. Windows does not need to know anything.
The only trouble I have with Ubuntu 16.0.4 is that after Suspend, open windows come back stuck to screen garbage. The only cure is to reboot.
Can anyone recommend a hardware / computer store in San Francisco who can assemble a deep learning box? I talked to Central Computer but their Ubuntu guy has been out for months due to family emergency and they will only install Windows. Checked on Yelp but other stores seemed to be mostly focused on minor repairs, not custom boxes.