Install Python, Theano, CUDA in Ubuntu


发布于

|

分类

Install Python, Theano, CUDA in Ubuntu

OK, finally I succeed.

To study Machine Learning, Python is the first choice. After 4 days’ learning the basic rules about Python, I go to the next step: Machine Learning.

Firstly, I installed Python(x,y) On my Windows 8.1 .The speed of Theano is so slow that i can’t tolerate, So I decide to run it on my GPU. But there is a question: CUDA’s version must be suit with the Python’s version, which means i should install 32-bit CUDA on my 64-Bit Windows for the Python in Python(x,y) is 32-bit. I can’t tolerate at all! Well, you know, 32-bit driver in 64-bit system will cause some unknown problem and at the same time, the machine won’t run at it’s full speed.What’s more, if I want to use CUDA in Windows, Microsoft VS Suit must be installed which is very huge and will make my computer mass. I HATE IT!!

I tried to replace the Python in Python(x,y), but failed.

So, I turned into Ubuntu.

How To

**There is a bug when you are using Wubi mode: You will see so many “DISK ERROR” when launching, and you can’t go into Ubuntu at all. Step 2~4 is the way to solve this problem. **
**If you have installed Ubuntu correctly, go to step 5 directly. **

  1. Firstly, Install Ubuntu using wubi mode.

  2. After installing, reboot. But * DO NOT GO INTO UBUNTU DIRECTLY *! Stay at the GRUB . Press E to edit the boot option. Find ro rootflags=sync, change it into rw rootflags=sync ( ro=>rw ), press F10 to continue booting.
  3. Open terminal, execute

    $sudo gedit /etc/grub.d/10_lupin

    Find the 150th line, change ro to rw , save the file.

    Back to terminal, execute

    $sudo update-grub

  4. Update the software info with $sudo apt-get update

  5. Install Theano and its rely-ons

    $sudo apt-get install python-numpy python-scipy python-pip python-nose g++

    $sudo pip install Theano

    Python 3.4+ have been correctly installed in ubuntu. If you like Python 2.7, run this(But it seems that it is unnecessary because the Python 2.7 have been installed??! OMG… Amazing…):

    $sudo apt-get install python-dev

    If you like Git, no problem:

    $sudo apt-get install git

    And I don;t know why I should install libopenblas-dev, but I installed…

    $sudo apt-get install libopenblas-dev

    It won’t take long.

  6. Run some test to see if these tools can be run:

    python

    import numpy;numpy.test();

    import scipy;scipy.test();

    import theano;theano.test();

  7. Install NVIDIA driver

    You can use the system’s additional-driver in system configuration -> software and updates -> additional drivers to install NVIDIA driver.

    You can also use $sudo apt install nvidia-331 to install it.

    To test if it’s correctly installed, use $dkms status.

    If you see the response like nvidia-331, 331.38, 3.13.0-24-generic, x86_64: installed, congratulations.

  8. Install CUDA

    $sudo apt install nvidia-cuda-toolkit

  9. Reboot your machine

  10. Actually, your installation is finished. To test, you can import theano;theano.test() in Python.

    If you see something like Using gpu device 0: GeForce GT 630M, Congratulations!

  11. Config
    sudo vim ~/.theanorc

[global]
floatX = float32
device = gpu

OK, enjoy it.

PS: Let’s have a bacon with the Dell’s FUN !

REFERENCE:


评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注