2016年7月20日 星期三

Install Nvidia driver with dkms may help you

DKMS is Dynamic Kernel Module Support, which can help you when you upgrade your kernel with the out come modules.

To install Nvidia Graphic Card driver with DKMS support, install DKMS first.
$ sudo apt-get install dkms
Then install the driver, take NVIDIA-Linux-x86_64-367.35.run for example
$ chmod +x  NVIDIA-Linux-x86_64-367.35.run
$ sudo sh NVIDIA-Linux-x86_64-367.35.run --dkms
When the installation finish
$ dkms status
You can find  "nvidia, 367.35, 3.19.0-64-generic, x86_64: installed".
And you can build all modules for current kernel by
$ dkms autoinstall
And for a specifi kernel by
$ dkms autoinstall -k 4.4.15 
Or install a module for all kernels
$ dkms install -m nvidia -v 367.35 --all

Reference  https://wiki.archlinux.org/index.php/Dynamic_Kernel_Module_Support

Nvidia Fan speed control

Login by Xwindow
Run nvidia-xconfig cool-bits=4
Then either run the bash file below or open Nvidia X Server Setting to change the fan speed

The bash file
#!/bin/bash
nvidia-settings -a [gpu:0]/GPUFanControlState=1
nvidia-settings -a [fan:0]/GPUTargetFanSpeed=100

2016年7月18日 星期一

compile kernel with minimum modules

Use the option localmodconfig to minize the modules.
But any change in hardware will make it need to be compiled again.
# get linux kernel source code
$ wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.15.tar.xz
$ tar -xvf linux-4.4.15.tar.xz
$ cd linux-4.4.15
$ make mrproper
$ cp /boot/config-$(uname -r) .config
$ make oldconfig
$ make localmodconfig
# compile kernel. revision is the tag you can customize. -j4 means using 4 threads
$ sudo fakeroot make-kpkg --initrd --revision=4.4.localmodconfig kernel_image kernel_headers -j4
# wait for a while

# you will find linux-headers-4.4.15_4.4.localmodconfig_amd64.deb and linux-image-4.4.15_4.4.localmodconfig_amd64.deb outside
$ ls ../linux*
# install them
$sudo dpkg -i ../linux*localmodconfig_amd64.deb

2016年7月13日 星期三

Tensorflow's docker image with gpu supported doesn't work

Nvidia driver要先裝好
https://github.com/NVIDIA/nvidia-docker/wiki/Installation

先裝docker-engine
https://docs.docker.com/engine/installation/
 再裝nvidia-docker
https://github.com/NVIDIA/nvidia-docker
使用Tensorflow Docker image(注1)
$ nvidia-docker pull gcr.io/tensorflow/tensorflow:latest-gpu
$ nvidia-docker run -it gcr.io/tensorflow/tensorflow:latest-gpu sh -c 'python -m tensorflow.models.image.mnist.convolutional'
結果 not find libcudnn.so

離開 container (Ctrl+D)

進入 container,使用bash
 $ nvidia-docker run -it gcr.io/tensorflow/tensorflow:latest-gpu bash
 連結
$ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.4 /usr/lib/x86_64-linux-gnu/libcudnn.so
Run again
$ python -m tensorflow.models.image.mnist.convolutional
結果
https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html#docker-installation 
注1: If cannot connect to the Docker daemon. Is the docker daemon running on this host?
http://stackoverflow.com/questions/33562109/docker-command-cant-connect-to-docker-daemon

2016年7月7日 星期四

global variable in bash

ether write in /etc/profile or add a sh in /etc/profile.d/

so making a file /etc/profile.d/cuda.sh
export LD_LIBRARY_PATH=/usr/local/cudnn/lib64:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
export PATH=/usr/local/cuda/bin:${PATH}
export CUDA_HOME=/usr/local/cuda
would make the variables for all users

reference:http://serverfault.com/questions/491585/is-there-a-global-bash-profile-for-all-users-on-a-system