Warning! This file is half outdated, and under active rewriting.
- Instructions to set up project cytometer.
- Table of Contents
- Installing the cytometer python code
- Dependencies and local conda environments
- Checking that your GPU is correctly set-up
- Configuring Keras to be used in a python script
- Configuring Theano to be used in a python script in a conda environment
- Configuring Tensorflow to be used in a python script in a conda environment
- Testing conda environment from the command line
- Packaging the cytometer python code
- Running cytometer python scripts
- Cloud computing on Amazon Web Services
Created by gh-md-toc
-
Clone the
cytometer
repository by running the commandcd ~/Software git clone https://[email protected]/MRC-Harwell/cytometer.git
-
Change directory to the project
cd cytometer
-
Make
install_dependencies_machine.sh
andinstall_dependencies_user.sh
executablechmod +x install_dependencies_machine.sh install_dependencies_user.sh
-
You only need to set up the machine once with
install_dependencies_machine.sh
(Ubuntu packages, nVidia drivers, etc). You will be asked for a sudo password, so you need to have sudo privileges./install_dependencies_machine.sh
-
You need to create a local conda environment with
install_dependencies_user.sh
for yourself (don't run it with sudo!)../install_dependencies_user.sh
-
The first time you run this it'll give an error message saying that you need to close your terminal for changes to take effect. Close your terminal and open a new one (or maybe run
source ~/.bashrc
). Run again./install_dependencies_user.sh
The install_dependencies_machine.sh
script:
- Installs the NVIDIA drivers rather than the open source nouveau (
xserver-xorg-video-nouveau
), so that we have full access to the NVIDIA graphic card features. - Uses Miniconda to install conda and create local python environments.
- Installs the CUDA Toolkit from the Nvidia website, rather than using Ubuntu packages.
-
Check that you get something similar to this on a terminal
$ nvidia-smi Wed Jun 28 15:20:35 2017 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 375.66 Driver Version: 375.66 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 Quadro K4000 Off | 0000:01:00.0 On | N/A | | 30% 39C P8 12W / 87W | 1490MiB / 3016MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1372 G /usr/lib/xorg/Xorg 365MiB | | 0 1974 G compiz 154MiB | | 0 2283 G ...el-token=493C1790BE0AE309A3CB57689C7C3E71 146MiB | +-----------------------------------------------------------------------------+
Note: In a laptop with a dual graphics chip configuration as explained above, you will get the same output whether the NVIDIA or Intel
chips are selected. Thus, regardless of what nvidia-smi
says, you still need to make sure you have selected the NVIDIA option in
nvidia-settings
.
-
Activate the cytometer local environment
source activate cytometer_tensorflow
-
Go to the scripts directory
cd ~/Software/cytometer/scripts
-
Mount or create the data and annotations directories required by the script. This depends on the script that you are going to run and your own machine setup
-
Run the script with
nohup
so you can close the terminal and leave it running, and useCUDA_VISIBLE_DEVICES
to choose one of the GPUs, e.g. for GPU=0. When the script starts processing a histology slide, it puts a lock on it by creating aHISTO_FILENAME.lock
file in the annotations directory. This way, you can run multiple instances of the script in parallel, one per GPU, each one processing a different histology slide. All the output from running the script will be redirected tonohup_${CUDA_VISIBLE_DEVICES}.log
export CUDA_VISIBLE_DEVICES=0 && nohup python tbx15_h156n_exp_0003_zeiss_full_slide_pipeline_v8_no_correction.py >> nohup_${CUDA_VISIBLE_DEVICES}.log &
You can launch the IDE from a terminal
PYTHONPATH=~/Software/cytometer LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH spyder &
Alternatively, set and export the environmental variables once
export PYTHONPATH=~/Software/cytometer:$PYTHONPATH
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
and then call the IDE as
spyder &
You can launch the IDE from a terminal
PYTHONPATH=~/Software/cytometer LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH pycharm-community &
Alternatively, set and export the environmental variables once
export PYTHONPATH=~/Software/cytometer:$PYTHONPATH
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
and then call the IDE as
pycharm-community &
You also have to select the python version in File -> Settings -> Project: scripts -> Project Interpreter.
For example, "Python 3.7 (cytometer) ~/.conda/envs/cytometer/bin/python"
You can run the script as
PYTHONPATH=~/Software/cytometer:$PYTHONPATH LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH python scripts/basic_cnn.py
Alternatively, set and export the environmental variables once
export PYTHONPATH=~/Software/cytometer:$PYTHONPATH
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
and then run the script as
python scripts/basic_cnn.py
- Create Amazon Web Services account.
- Log into your AWS Management Console.
- Choose Launch a virtual machine.
- Click on "EC2 Instance", "Get Started".
- Choose a name for the EC2 Instance, e.g. "cytometer-basic-cnn".
- Select an Operating system, e.g. Ubuntu (Server 16.04 LTS at the time of this writing).
- Select as instance type "t2.micro" (1 Core vCPU (up to 3.3 GHz), 1 GiB Memory RAM, 8 GB Storage).
- Create a key pair, by clicking on "Download" and saving the private key
cytometer-basic-cnn.pem
to e.g.~/Software/cytometer/private_keys
.
- If you lose the private key, you won't be able to recover it, or connect to the instance.
-
Click on "Create this instance". Wait a bit until the instance is created.
-
Click on "Proceed to EC2 console"
-
Right click on your instance and select "Connect".
-
Enable connections from your machine.
-
Go to your instance -> Network & Security -> Security Groups.
-
Go to this intance's group, e.g. "cytometer-basic-cnn" -> Inbound.
-
Make sure there's a rule
SSH TCP 22 YOUR_PUBLIC_IP/32
where YOUR_PUBLIC_IP is the IP address your machine provides to the external world. The autodected one may be wrong. You can find it by e.g. googling "What's my ip"
-
Follow the instructions to connect with a command line SSH client or a Java SSH client from the browser (the latter no longer supported by the Google Chrome browser). For example, if you are going to use the command line SSH client,
-
Make the private key not publicly readable
cd ~/Software/cytometer/private_keys chmod 400 cytometer-basic-cnn.pem
-
Connect to the instance
ssh -i "cytometer-basic-cnn.pem" [email protected]
where
XXX-XX-XX-XX-XX
is a code specific to your instance.
-
Run from the command line something similar to this (this one copies file
install_dependencies.sh
to the remote instance)scp -i private_keys/cytometer-basic-cnn.pem install_dependencies.sh [email protected]:~/
The setup.py
and associated files to create a package are in place. For the moment, you can create a python source package (not exactly what we need to install with pip
) with
cd ~/Software/cytometer
./setup.py sdist