顯示具有 Linux 標籤的文章。 顯示所有文章
顯示具有 Linux 標籤的文章。 顯示所有文章

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月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

2016年6月12日 星期日

Install cuda on ubuntu

其實有很多教學了,有個小小的點是,如果你有多顯卡,在關閉開源社群的driver nouveau的時候可能會完全沒有畫面,但其實已經開好機在等你login了

Through there are many web pages teach you how to install cuda on ubuntu, I encounter a problem that I have multiple vga cards(HD4000 and 660ti) in my computer, when I follow their instruction to close the driver, nouveau, from open source community, then I boot with whole black screen. Actually, the computer is there waiting for you to login!

So I use SSH to continue the installation.

我個人的作法
Download cuda_7.5.18_linux.run from Nvidia website
$ chmod +x cuda_7.5.18_linux.run
$ sudo ./cuda_7.5.18_linux.run
Follow the installation
It tell you that you have to reboot because nouveau is working
It actually make a file in /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
And its content is
blacklist nouveau
options nouveau modeset=0

And it run "$ sudo update-initramfs -u" to modify the modules in initramfs.

OK, you know what it have done to your computer now, and let's reboot.

If you find that there is whole black waiting for you, and you don't have ssh installed, try recovery mode, I just give keywords here.
boot in root shell
$ mount [sdXy] / -o remount,rw # [sdXy] is your disk partition where / locate
$ rm /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
$ update-initramfs -u
$ reboot
Then you can boot normally into the familiar ubuntu desktop, and then install ssh., then run the previous procedure again.

OK, we have ssh now. Use other computer to login the poor computer.

$ sudo service lightdm stop  # This doesn't do anything for me.
$ sudo killall xorg                 # But this does.
$ sudo ./cuda_7.5.18_linux.run
Follow the instructions to install Nvidia driver and CUDA.

Add the two line to the bottom of the file .bashrc in your home directory.

export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
export PATH=/usr/local/cuda/bin:${PATH}


Then
$ source ~/.bashrc 

Remember to run following command to have a good xconfig file for your card, or it may still become a workstation that you are only able to access through ssh or telnet.
$ nvidia-xconfig

Then reboot, bless you to see your familiar ubuntu desktop again.

2016年6月1日 星期三

手動設定Ubuntu的nameserver(dns)、固定IP

To set remote dns server manually, we have to modify the file, "/etc/network/interface" .

To set 8.8.8.8 as our name server, add "dns-nameservers 8.8.8.8" to the file.

And to set the static IP, modify the file "/etc/network/interface" as well.
# The primary network interface
auto ens33
iface ens33 inet dhcp
change dhcp to static, and add information you need.

e.g.
# The primary network interface
auto ens33
iface ens33 inet static
address 192.168.20.103
netmask 255.255.255.0
gateway 192.168.20.1

Then "sudo systemctl restart networking.service" or "sudo /etc/init.d/networking restart" to make the modification effective.

2015年10月7日 星期三

SSD optimizing in linux

If your are using ext4 as file system in SSD, you may consider add discard and noatime parameter in /etc/fstab.
discard makes it trim. And noatime makes it not modify the last read time information for file.

And you can change CFS i/o scheduler to noop scheduler.
The approach is to modify the /etc/default/grub, add elevator=noop in kernel parameter.
And do
update-grub
Or if you have many storage devices not only SSD but also motion driven devices, you can  edit or create a file in
/etc/udev/rules.d/60-schedulers.rules
contains
# set noop scheduler for non-rotating disks 
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="noop" 
# set cfq scheduler for rotating disks 
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="cfq"
And use
cat /sys/block/sda/queue/scheduler
to see the scheduler status.

2015年10月3日 星期六

test disk speed

hdparm -Tt /dev/sda

mount /dev/sda at /test
dd if=/dev/zero of=/test bs=1M count=1024

iotop
iometer
iozone

2015年9月25日 星期五

An easy way to parallel your c code by using openmp

if your code has low dependencies between each others, you can just use openmp to parallelize your code.
In ubuntu, openmp is installed defaultly, so we don't need to install anything.
In your code, add
#include <omp.h>
in headers.
And add
#pragma omp parallel for
before your for loop.
like

And compile with flag -fopenmp.
gcc ctest.c -fopenmp .....
Then it would run like this.