Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.




Warning
As a disclaimer, these instructions are dangerous and informational only and should only be used as a last resort as it can disable your ability to use your CoE Account if done incorrectly.  It is highly encouraged to talk to your TA before proceeding. Do not proceed if you do not know how to restore a bashrc file. Do not proceed if you have less that 4 GB free for quota. All commands are for Centos operating system only (linux01.engr.ucsb.edu to linux28.engr.ucsb.edu).




Occasionally for research or classes you need a different version of python and pip than what is installed on the COE machines. Sometimes you can get away with just using a virtual environment that allows you to install custom python packages and sometimes you need something more due to your software needing to reach outside the python environment. Due to security and privacy concerns we do not grant root, dnf, yum, and/or sudo access to our lab machines. However, that does not mean you cannot get your desired python package another way.

...

Change directory to your desktop using “cd Desktop” If you do not change directory you will get permission denied errors. By installing on the desktop, if you mess up, you only mess yourself up.

1. Install python to your desktop

*Disclaimer: all commands are assuming centos operating system (linux01.engr.ucsb.edu to linux28.engr.ucsb.edu in the Honea Lab a.k.a back room of CSIL)

Code Block
languagebash
themeEmacs
mkdir ~/python 
cd ~/python
wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz --no-check-certificate
tar zxfv Python-2.7.11.tgz
find ~/python -type d | xargs chmod 0755
cd Python-2.7.11

compiled the source following its guideline

Code Block
languagebash
themeEmacs
./configure --prefix=$HOME/python
make && make install

Notice the prefix option, it is mandatory for this to work. The value of prefix option is to specify where to put the related output of make command, by default it is in the /usr/local/ and we don't want that so we use our own customized directory. For most people that will be /fs/student/yourCOEaccountYourCOEaccount

Here comes another important step. By the default, if we type python command, it will use the default python of the system. We are going to update the environment variables to force the shell to use our new python. Edit ~/.bashrc_profile and add the following lines to the end:

Code Block
languagebash
themeEmacs
export PATH=$HOME/python/Python-2.7.11/:$PATH
export PYTHONPATH=$HOME/python/Python-2.7.11

Finally, refresh the current session by running the command:

Code Block
languagebash
themeEmacs
source ~/.bashrc_profile

You might need to logout and login again for the environment to update properly. At this point, you should be able to see a new python. To check, run this command:

Code Block
languagebash
themeEmacs
which python

it should show you the path to the python binary file, which is located in your home directory: ~/python/Python-2.7.11/python

2. Install pip

Pip is a program used to help us easily install python packages, it is similar to rubygems in Ruby world. After installing python locally as described in the first step, it is very easy to install pip.

Run the following command to install pip as a local user

Code Block
languagebash
themeEmacs
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py -O - | python - --user

...

After finishing the installation, we need to update our PATH variable. Open ~/.bashrc_profile and add the following line:

Code Block
languagebash
themeEmacs
export PATH=$PATH:$HOME/.local/

...

binAgain, reload the session by the command source ~/.bashrc_profile or logout and login. Then, check if pip command is available:


Code Block
languagebash
themeEmacs
which pip

It should show a path pointing to your local directory: ~/.local/bin

Having both python and pip installed as a local user, you can install any other packages you want without worrying about other parts of the whole system. This is extremely useful in case you want to experiment with new things.

...

http://thelazylog.com/install-python-as-local-user-on-linux/

3. Install Cuda (optional for most users)

Cuda is the Nvidia API. There are several programs that use it. Tensorflow, Caffe, Pytorch all use Cuda in various capacities. To get cuda go to https://developer.nvidia.com/cuda-downloads

...

4) Enter the toolkit location since the default install location will give you errors: ~/Desktop/cuda

5) Do not install symbolic link

...

You will then have to modify your bashrc file again so that the PATH includes ~/Desktop/cuda/bin

If you did everything right, typing “./nvcc -V” Vshould now give you the cuda version number.

...