Configuring kubuntu linux

New step by step installation on ubuntu (20190220)

==installation of cuda==
=Preinstallation actions==
a. verify cuda-capable gpu
lspci | grep -i nvidia

b. verify a supported version of linux
uname -m && cat /etc/*-release

c. verify the system has gcc installed
gcc --version


1. disabling nouveau
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#package-manager-metas
if lsmod | grep nouveau prints anything, means nouveau is loaded and must be disabled before proceeding to install cuda

navigate to /etc/modprobe.d/

sudo nano ./blacklist.nouveau.conf

enter the following in the file
blacklist nouveau
options nouveau modeset=0

save

regenerate the kernel initrd:
sudo update-initramfs -u

==download cuda 9 deb from nvidia==
navigate to download
sudo dpkg -i cuda-repo-ubuntu~~~~.deb

installe public gpg key
sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub 

sudo apt-get update
sudo apt-get install cuda

==postinstallation operations==
edit ~/.bashrc

export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}


==installation of cudnn==
used version 
libcudnn7_7.0.5
libcudnn7-dev_7.0.5.15-1 for cuda9.0

navigate to download
sudo dpkg -i libcudnn7_~~~.deb
sudo dpkg -i libcudnn7-dev~~~~.deb




==install python 3 and virtualenv==
sudo apt update
sudo apt install python3-dev python3-pip
sudo pip3 install -U virtualenv

==install tensorflow==
create a new virtual environment
virtualenv --system-site-packages -p python3 tensorflow

source tensorflow/bin/activate

pip install --upgrade pip
pip list

pip install tensorflow-gpu==1.7.0

test tensorflow installation
source tensorflow/bin/activate
python
import tensorflow as tf

should be no error



==install other dependencies for usiigaci==

pip install opencv-python tqdm docopt imgaug h5py
pip install keras==2.1.5




miscellneous
installation of exfat
sudo apt-get install exfat-fuse exfat-utils















Setting up virtual environment for deepcell
virtualenv /home/davince/deepcell2

install all dependencies.

start virtual environment by
source deepcell2/bin/activate
close the virtual environment by
deactivate

using a virtualenv in an ipython notebook
pip install ipykernel
python -m ipykernel install --user --name=deepcell2

then virtualenv is available in ipython kernel



troubleshooting
1.
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/usr/local/lib/python2.7/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax
Aborted (core dumped)

The bug mentioned on stackoverflow has been fixed to make the bash search for python2 if python 3 is not used.
If such error exists and prevent you to use virtualenv to set up environment.
Try nano ~/.bashrc, look for pythonpath.
it should be just the path for cuda and the primary python. delete others.
for example, i was also playing around with caffe source code and thus have it in the bashrc as a pythonpath and that give me the trouble.

2. problem with pygpu?
if there is no conda on the linux. build libgpuarray from source.
run sudo ldconfig to update and reboot

3. error with something associated with json when going keras 1.1.0
when going keras 2 maybe ok. but deepcell is not yet supported by keras 2(work in progress, would love some help)

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/home/h/hftsai/deepcell/lib/python2.7/site-packages/keras/__init__.py", line 2, in <module>

    from . import backend

  File "/home/h/hftsai/deepcell/lib/python2.7/site-packages/keras/backend/__init__.py", line 29, in <module>

    _config = json.load(open(_config_path))

  File "/apps/free/python/2.7.10/lib/python2.7/json/__init__.py", line 290, in load

    **kw)

  File "/apps/free/python/2.7.10/lib/python2.7/json/__init__.py", line 338, in loads

    return _default_decoder.decode(s)

  File "/apps/free/python/2.7.10/lib/python2.7/json/decoder.py", line 369, in decode

    raise ValueError(errmsg("Extra data", s, end, len(s)))

ValueError: Extra data: line 2 column 1 - line 4 column 1 (char 85 - 255)

maybe it's due to redundant description for kerasbackend
go nano ~/.keras/keras.json
check if theres is only 1 set of 
{
    "image_dim_ordering": "tf",
    "epsilon": 1e-07,
    "floatx": "float32",
    "backend": "tensorflow"
}

Comments