Archlinux + CUDA on Ivy-Bridge + Kepler
Introduction
My new Asus N56V arrived earlier this week, and the first thing I wanted to do was install ArchLinux on it. Being a CUDA programmer by profession I also needed to get it working with the Optimus configuration NVIDIA GPUs have to work with on board Intel Graphics cards.
Being a new arrival in the market it has had some issues. Some due to my unfamiliarity with them (such as grub2 and UEFI) and others such as lack of availability (such as drivers for the ethernet).
Thankfully, the internet has been helpful; Sometimes providing outright solutions, sometimes guiding you in the right direction. Since I had to scour through the web to figure out the many issues facing me, I think putting together this guide (by no means fool proof or comprehensive) should be helpful to those with similar hardware in the future.
Here is the hardware configuration:
| CPU | Intel 3610QM |
| GPU | NVIDIA GT 650M |
| Ethernet | AR8161 |
| Wireless | AR9485 |
Preinstallation
Installation Media
I chose to use the Netinstall Image (dated August 2011) because it is quicker to download. It can also automatically download and install the latest packages over the internet. If you have a slow ineternet connection or already have Core Images of archlnux it is best to use the core image.
Preparing the disks
The laptop came with UEFI enabled and the harddisk using GPT as its partitioning table. Why choose this over regular BIOS I am not sure. If your laptop uses UEFI, while you can partition and format the disks from the archlinux live image, it is best if you create the required partition (and format them as ntfs for now) from Windows or any other utility before you proceed with the installation.
Guides
Please have the Archlinux Beginners guide open at all times. It is absolutely necessary for beginners and highly recommended for everyone else. For a forgetful person like me it saved my ass more than a few times. This guide about setting up ArchLinux with UEFI is also helpful. I had to change a couple of paths, but we will get to that later.
UEFI setup
If you have an UEFI setup, you will need to create a bootable flash drive with an UEFI shell. Have a flash drive (256MB should be more than enough) formatted as FAT32. Download the appropriate shell from here. And rename it as bootx64.efi and place it in /path/to/flashdrive/efi/boot/bootx64.efi
This will be useful for later.
Installation
Network
The following command should show you the networking devices that are readily available.
ip addr
If you can see eth0 and have an ethernet cable, then running dhcpcd should allow you to connect to the internet directly. If you can not see eth0 or want to use wifi, you can set up WPA connections in the following manner.
ip link set wlan0 up wpa_passphrase ssid “passphrase” > /etc/wpa_supplicant.conf wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf iwconfig wlan0 dhcpcd wlan0 ping -c3 www.google.com # Testing the network |
You can find the instructions for setting up other kinds of networks over here.
Partitioning the disks
This section is in case you have not created the partitions you want already. If the laptop is using GPT tables, the archlinux installer will not be able to detect free space for you to set up the partitions. You will need to install gptfdisk and create partitions.
pacman -S gptfdisk gdisk # instructions exactly like fdisk # create partitions and write to disk |
At this point I needed to reboot the system for the changes to be identified. Painfully I had to set up the wifi again (and everytime after that if you reboot your system and end up in the live session).
Starting the install process
from the prompt run the following
/arch/setup
The best thing to do here is to follow the Beginners guide. I will try to provide the options I chose.
You will be asked to select a server to download from if you are using a net install. Choose the server that is closest to you. For those in USA, rit.edu should work well.
When prompted to select repositories and packages, choose what is relavent to you. I chose the following.
Repositories: core-remote extra-remote community-remote
Packages: xorg, xorg-font, gnome, gnome-extra
Packages: boost, boost-libs, emacs, gcc-fortran, libreoffice
If you are using an Optimus setup machine, DO NOT SELECT nvidia or nvidia-utils. You can always install additional packages after archlinux is setup.
Next you will be prompted to prepare the hard disks. Do not wipe the entire disk (unless that is what you intend to do). Select the manual setup and use the layout you want. Now proceed to the installation step where the installer will try to download packages over the network and install them. This will take about 10 – 20 minutes (depending on the machine and the packages selected), so it would be a good time for a coffee break.
At the end of the install process you will be asked to configure your system. The only real things you need to care about are rc.conf and pacman.d/mirrorlist.
Add your machine’s name at the end of HOSTNAME in rc.conf like so:
HOSTNAME=”archer”
Edit pacman.d/mirrorlist and uncomment the servers that are nearest to you. I chose rit.edu because their servers seem to be in sync the most.
Next setup your root password, and proceed to finish the setup. You will be asked about the location grub needs to be installed. Choosing /dev/sdX (sdX is where archlinux is installed, for most it is /dev/sda) should finish the setup and you can boot into archlinux.
For those using UEFI however, you will be notified that the procedure failed. This is expected and can be remedied.
Setting up UEFI entry
If you are not using an UEFI machine, please skip over this part. For those of you still here, this is what needs to be done.
Chrooting to archlinux
mount /dev/your_root_partition /mnt/ mount /dev/your_boot_partition /mnt/boot # Only if you have seperate boot partition mount -o bind /dev /mnt/dev mount -t proc /proc /mnt/proc/ mount -t sysfs /sys /mnt/sys/ chroot /mnt bash mkdir /boot/efi mount /dev/your_efi_partition /boot/efi pacman-db-upgrade pacman -Syy |
Time to install grub
pacman -S grub2-efi-x86_64 grub-install –directory=/usr/lib/grub/x86_64-efi –target=x86_64-efi –efi-directory=/boot/efi –bootloader-id=Archlinx –boot-directory=/boot –recheck –debug |
However it will fail to add an entry to EFI with the following error
Fatal: Couldn’t open either sysfs or procfs directories for accessing EFI variables
Run the following to finish setting up grub 2 before fixing EFI.
grub-mkconfig -o /boot/grub/grub.cfg |
The flash drive
This is when you use the flash drive created earlier. Plug it in, reboot, choose to boot from the flash drive. Once you are in the shell, type the following:
bcfg boot add 0 fs0:\efi\Archlinux\grubx64.efi “Arch Linux” |
This will create a temporary entry with which you can boot into ArchLinux.
Finishing it off
Reboot machine, choose “Arch Linux” entry from EFI table. You will be logged into Arch Linux. However this is a one time thing and you will need to make it permanent by running the following command
grub-install –directory=/usr/lib/grub/x86_64-efi –target=x86_64-efi –efi-directory=/boot/efi –bootloader-id=Archlinx –boot-directory=/boot –recheck –debug |
Reboot and choose “Archlinux” as the boot option and you should be good to go!
Post installation
Ethernet
Apparently the driver required for this card has not yet been merged into the linux kernel. However the linuxfoundation website explains how to set it up.
Step 1: Download the driver. Unpack it.
Step 2: Install the driver.
./scripts/driver-select alx make sudo make install |
Step 3: Reboot. You now have ethernet.
X and Graphics
For those of you unfamiliar with Archlinux, the initial setup is very minimal. It is command line only and you will need to set up the X server and the relavent drivers
pacman -S xf86-video-intel xorg-server xorg-xinit xorg-server-utils |
To test X
pacman -S xorg-twm xorg-xclock xterm
startx |
You should a minimal X come up. Exit it to continue with the rest of the setup.
Creating users
adduser username pacman -S sudo visudo # Give the user sudo permissions |
Installing a desktop manager
This is where the installation steps may not be relavent to most people. I prefer gnome 3 over the other alternatives. You can replace gnome and gdm with their equivalents for the dm of your choice.
Log out as root, login with your user name.
sudo pacman -S dbus gnome gnome-extras networkmanager network-manager-applet sudo rc.d start dbus sudo rc.d start gdm # should bring up the login screen |
after logging in,
- edit /etc/rc.conf and add dbus to DEAMONS immediately after syslog-ng
gnome 3.4 uses systemd instead of initscripts for a few things, including time and rc.local
You will need to do the following to set them up.
pamcan -S systemd systemd-arch-tools initscripts-systemd systemctl enable gdm.service systemctl enable NetworkManager.service systemctl enable rc-local.service |
Edit /etc/default/grub and add the following just below a similar line
GRUB_CMDLINE_LINUX=”init=/bin/systemd”
run the following command and reboot
grub-mkconfig -o /boot/grub/grub.cfg |
Installing other packages
Sound:
pacman -S pulseaudio |
Touchpad:
pacman -S xf86-input-symantics |
Skype:
Edit /etc/pacman.conf. Uncomment multilib repository.
pacman -Syy pacman -S lib32-pulseaudio skype # skype only available for 32 bit |
Packer:
A package manager for third party Arch User Repository (AUR)
Download packer tarball
unpack tarball and cd into the directory
makepkg pacman -S jshon pacman -U packer-* |
Installing nvidia driver
Since NVIDIA does not officially support Optimus on linux, the opensource project bumblebee is filling its shoes. You can set this up quite easily if you already installed packer (or other AUR helpers)
packer -S bumblebee bbswitch packer -S nvidia-bumblebee nvidia-utils-bumblebee sudo usermod -a -G bumblebee $USER |
edit /etc/rc.conf and add nvidia to end of MODULES and @bumblebeed to end of DAEMONS
For some of you this may be enough. But just to be extra careful, create the following script and name it nvwake
This makes sure the nvidia module is loaded and /dev/nvidia0 and /dev/nvidiactl are created (which are required for those who intend to use CUDA)
#!/bin/bash /sbin/modprobe nvidia if [ "$?" -eq 0 ]; then # Count the number of NVIDIA controllers found. N3D=`lspci | grep -i NVIDIA | grep "3D controller" | wc -l` NVGA=`lspci | grep -i NVIDIA | grep "VGA compatible controller" | wc -l` N=`expr $N3D + $NVGA - 1` for i in `seq 0 $N`; do mknod -m 666 /dev/nvidia$i c 195 $i done mknod -m 666 /dev/nvidiactl c 195 255 else exit 1 fi |
Now make it executible and make sure it gets run at startup (by putting it in rc.local)
chmod +x nvwake sudo echo /path/to/nvwake >> /etc/rc.local # make sure it is run at startup |
Installing CUDA
This is the easiest part.
pacman -S cuda-toolkit cuda-sdk # should install opencl-nvidia |
Reboot!
Welcome back.
You don’t need to do anything special for CUDA programs.
You can test if everything is alright by running the following
sudo make -C /opt/cuda-sdk/C/ -j # why use only one thread? /opt/cuda-sdk/C/bin/linux/release/deviceQuery /opt/cuda-sdk/C/bin/linux/release/deviceQueryDrv |
To run any graphics examples you need to use optirun like this:
optirun glxgears optirun glxspheres |
They may take some time to load though.
And that is it.
Happy hacking!
EDIT
Added some more information about CUDA since it felt a bit abandoned.
If any of you are having trouble, leave a comment or dm me @pavan_ky on twitter.
Hi, I wonder what nvidia driver version you are using, and what PCI ID your Nvidia card has, because on my laptop I have:
$ lspci -s 01:00.0 -vvnnqq
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation Device [10de:0fd1] (rev ff) (prog-if ff)
!!! Unknown header type 7f
(that’s a 650M in MSI GE60 laptop), and the driver refuses to load:
[ 3452.503291] NVRM: The NVIDIA GPU 0000:01:00.0 (PCI ID: 10de:0fd1) installed
[ 3452.503292] NVRM: in this system is not supported by the 295.53 NVIDIA Linux
[ 3452.503293] NVRM: graphics driver release. Please see ‘Appendix A -
[ 3452.503294] NVRM: Supported NVIDIA GPU Products’ in this release’s README,
[ 3452.503295] NVRM: available on the Linux graphics driver download page at
[ 3452.503296] NVRM: http://www.nvidia.com.
[ 3452.503306] nvidia: probe of 0000:01:00.0 failed with error -1
[ 3452.503319] NVRM: The NVIDIA probe routine failed for 1 device(s).
[ 3452.503321] NVRM: None of the NVIDIA graphics adapters were initialized!
Hm, after a reboot the driver loads, but optirun nvidia-settings -c :8 induces an error:
[ 797.275743] NVRM: GPU at 0000:01:00.0 has fallen off the bus.
[ 797.275754] NVRM: GPU at 0000:01:00.0 has fallen off the bus.
Hi Alexander,
I am using nvidia-bumblebee from the AUR repository to the install driver. The driver version is 295.53. The kepler gpu needs atleast 295.41 to work.
Here is my output
lspci -s 01:00.0 -vvnnqqSERR-
Latency: 0
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation Device [10de:0fd1] (rev a1) (prog-if 00 [VGA controller])
Subsystem: ASUSTeK Computer Inc. Device [1043:2103]
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort-
Interrupt: pin A routed to IRQ 16
Region 0: Memory at f6000000 (32-bit, non-prefetchable) [size=16M]
Region 1: Memory at e0000000 (64-bit, prefetchable) [size=256M]
Region 3: Memory at f0000000 (64-bit, prefetchable) [size=32M]
Region 5: I/O ports at e000 [size=128]
[virtual] Expansion ROM at f7000000 [disabled] [size=512K]
Capabilities:
Kernel driver in use: nvidia
So, does optirun actually work for you? I get a “fallen off the bus” error unless I invoke it after running some cuda program, in which case I get a strange error about how ConnectedMonitor should be “”: https://gist.github.com/2884514
One more question: what does the following command print for you?
nvidia-xconfig –query-gpu-info
One more… what does ‘xrandr’ print?
Hi Alexander,
Here are my outputs.
$ xrandr
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
LVDS1 connected 1366×768+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
1366×768 60.0*+
1024×768 60.0
800×600 60.3 56.2
640×480 59.9
VGA1 disconnected (normal left inverted right x axis y axis)
$ nvidia-xconfig -query-gpu-info
Number of GPUs: 1
GPU #0:
Name : GeForce GT 650M
PCI BusID : PCI:1:0:0
Number of Display Devices: 0
bbswitch was giving some issues so I had to uninstall it and disable it. The cuda programs run as long as “nvidia” module is loaded. graphics + optirun is acting a bit iffy. But restarting the laptop usually fixes the issues I am facing.
If you want to have a chat, I will be on #archlinux on freenode. My id is pavanky.
Can you please show your bumblebee config files (especially /etc/bumblebee/xorg.conf.nvidia) and Xorg.8.log that is generated after a successful use of optirun+graphics program?
I noticed something interesting that I haven’t noticed before. If I run optirun glxgears (or any other graphics program) before I run CUDA programs, my machine just shuts down (and no logs to show for it)!
But if I run a simple CUDA program (deviceQuery from the SDK, which works) and then run optirun glxgears, it works.
Here are my log files for reference. The Xorg.8.log is the output when I successfully ran glxgears after running deviceQuery
https://gist.github.com/2890218
Hi !
Thanks for you review, I have a N76 (so the basic hardware is the same) and I’ll use this page when I’ll do the install of Archlinux, the distro that I usually use on my PCs !
Hi pavanky,
I saw that you asked in the #bumblebee chatroom about the cuda-before-optirun issue. Looks like several people have such symptoms. I created an article on NVNews forums to let users and nvidia devs know:
http://www.nvnews.net/vbulletin/showthread.php?t=184542
Hi, I recently bought an asus N56VM i have the exact same ethernet and wireless (eth: AR8161, wlan: AR9485). My problem is that arch linux didn’t recognize neither of them. I tried Netistall 2011, netinstall 2012(from org/archiso), Core 2011, Core 2012 but still had no internet connection. How do you managed to use them?
Ok i managed to make the wifi working… Installing archlinux now…
The first command was wrong for me, i mean:
ip addr link set wlan0 up
The correct one was (for me at least, with netinstall 2011):
ip link set wlan0 up
I am unable to install the ethernet driver, the make return me various error…
Roberto,
Can you show what kind of errors you are getting ?
Sorry for the delay but i was working outside my city in the last 4 days and i didn’t have my laptop with me… So this is the error i got:
[kicka@lab-mobile compat-wireless-2012-06-29]$ sudo ./scripts/driver-select alx
Password:
Processing new driver-select request…
Backup exists: Makefile.bk
Backup exists: Makefile.bk
Backup exists: drivers/net/ethernet/broadcom/Makefile.bk
Backup exists: drivers/net/ethernet/atheros/Makefile.bk
Backup exists: Makefile.bk
Backup exists: Makefile.bk
Backup exists: drivers/net/ethernet/broadcom/Makefile.bk
[kicka@lab-mobile compat-wireless-2012-06-29]$ make
make -C /lib/modules/3.4.4-2-ARCH/build M=/home/kicka-Cinnamon/compat-wireless-2012-06-29 modules
make[1]: Entering directory `/usr/src/linux-3.4.4-2-ARCH’
scripts/Makefile.build:44: /home/kicka-Cinnamon/compat-wireless-2012-06-29/drivers/net/ethernet/atheros/alx/Makefile: File o directory non esistente
make[4]: *** Nessuna regola per generare l’obiettivo «/home/kicka-Cinnamon/compat-wireless-2012-06-29/drivers/net/ethernet/atheros/alx/Makefile». Stop.
make[3]: *** [/home/kicka-Cinnamon/compat-wireless-2012-06-29/drivers/net/ethernet/atheros/alx] Errore 2
make[2]: *** [/home/kicka-Cinnamon/compat-wireless-2012-06-29/drivers/net/ethernet/atheros] Errore 2
make[1]: *** [_module_/home/kicka-Cinnamon/compat-wireless-2012-06-29] Errore 2
make[1]: Leaving directory `/usr/src/linux-3.4.4-2-ARCH’
make: *** [modules] Errore 2
[kicka@lab-mobile compat-wireless-2012-06-29]$
Ok i managed to install it but in a different way…
I’ve downloaded the file compat-wireless from
http://www.archlinux.it/forum/viewtopic.php?f=23&t=14899
then unzipped and:
makepkg -g >> PKGBUILD
makepkg -i
Worked like a charm… I do not know why all of the other methods doesn’t work for me, neither the aur compat-wireless or the ones downloaded from the sites you suggested… but in this way i now have ethernet working.
Hi Roberto,
Sorry about the delay. I think a “make clean” would have solved the issue.
As predicted, I’ve used this guide to install Archlinux on my Asus N76, dual boot (with Win7) in UEFI mode with the help of rEIFnd and grubx64-efi.
All is working but the multimedia keys and the keyboard backlight. Do you know how to proceed ?
I managed to correct the multimedia keys and the keyboard backlight (at least in Gnome/Cinnamon in KDE still no luck…) throughtout a a patch for the kernel that resolves 80% of the problems… it will be included in the kernel streamline in the next releases (howewer at the moment still no patch in the 3.5.1 kernel) so it will be just a matter of time, but if you are like me… here’s what i did:
I have no more:
ASUS_WMI can’t find DSTS
at boot time, the keyboard backlight works, Volume keys works, illumination led and wireless led working, wireless key working, etc…
I still aren’t pleased enough ‘cos to put the patch into my kernel i builded a new one with the patch integrated inside and then i install it. This means more than 2 hour to compile the kernel. There is a packet for ubuntu that add this patch directly into your installed kernel and furthermore it use dkms systems… this means that everytime you upgrade the kernel this patch will be automatically implemented into it. This solution is the ideal in my humble opinion… So i’m trying (with no luck) to do a PKGBUILD that just do that…
At the end of the comment there is the links for the kernel 3.4.8.1 generic + the patch, just download, go into the directory where you have those two files and simply open a terminal and write:
sudo pacman -U *.*
(Better if you have only this two package in that directory otherwise substitute *.* with the two names of the files…)
Reboot
Now Everything work fine
(The keyboard backlight is OFF by default, simply push 1 time Fn – F3 and then Fn – F4)
I add the patch file too.
Kernel-Headers : http://dl.dropbox.com/u/9174110/linux-headers-3.4.8-1-x86_64.pkg.tar.xz
Kernel: http://dl.dropbox.com/u/9174110/linux-3.4.8-1-x86_64.pkg.tar.xz
Asus-WMI.patch: http://dl.dropbox.com/u/9174110/asus-wmi.patch
PS: Happy Asus N56 To Everyone!
EDIT: today i upgraded my kernel to 3.4.9 and with my totally happiness they integrated the patch so no need anymore of my files… just upgrade the kernel to 3.4.9 or superior.
Still no eth we have to go still with compat-wireless
PS: the keyboard backlight is still off by default…
I’m the king of the rez of dead post !
I haven’t use Arch very much since the installation (but have kept it updated).
I haven’t seen your answer within many days so I forget this post after -_-.
I just find it again ’cause I want to enable subwoofer, keyboard backlight and fn keys.
I’m now with the 3.6.6-1 kernel and I would like to know how do you achieve to make all of that working.
Maybe you should make a page on the arch wiki, giving these useful instructions more visibility, ’cause it seems to be more and more common to post install guide for particular hardware/laptop on the wiki.
I hope you’ll get notified for this undead message !
Solution for my self and maybe others : https://wiki.archlinux.org/index.php/ASUS_Zenbook_Prime_UX31A
It’s relevant for the keyboard backlight (use of asus-keyboard-backlight AUR package) and the LCD brightness (use of asus-screen-brightness AUR package).
But maybe there is other “cleaner” solution that doesn’t involve the use of such packages ?
I’ll be happy to ear
Hi pavan
I recently bought an Alienware m14x laptop with core-i7 3610QM cpu and nvidia gt650m gpu. I want do do cuda programming on it. Can you suggest what would be best linux distro for this purpose in terms of ease?(Right now I write cuda programs on machines that already have it up and running with fedora and ubuntu with gt 545 and tesla respectively)
If I decide to use archlinux, will my procedure be same as above?(I don’t think I have this UEFI thing on my alienware)
cheers
Jayant
Jayant,
Any distro you choose will probably work just fine with bumblebee installed. Stick yo Fedora / Ubuntu if you have not tried ArchLinux already.
Hi pavan,
i hope u can help me.
My CUDA still doesnt work.
My deviceQuery looks like this:
Found 1 CUDA Capable device(s)
Device 0: “GeForce GT 650M”
CUDA Driver Version / Runtime Version 4.20 / 4.0
CUDA Capability Major/Minor version number: 3.0
Total amount of global memory: 2048 MBytes (2147287040 bytes)
MapSMtoCores undefined SMversion 3.0!
MapSMtoCores undefined SMversion 3.0!
( 2) Multiprocessors x (-1) CUDA Cores/MP: -2 CUDA Cores
GPU Clock Speed: 0.41 GHz
Memory Clock rate: 900.00 Mhz
Memory Bus Width: 128-bit
Have u ever seen “-2 cuda cores” like this?
thx for help
You may need to install the latest cuda toolkit (CUDA 4.2). The 4.0 does not support Kepler!
Hey,
Thanks for the useful guide, I’m about to install Arch to dualboot with Windows 7 on my Lenovo u410.
- It comes with an SSD and a 500GB HDD
- I need to dualboot with the existing Windows installation, I’ve created the partition on Windows 7 (on the HDD), I assume this guide is for dualbooting with an existing windows installation and does not require re-installing windows if all goes well.
- Any thoughts about repartitioning the SSD itself?
I have dual booting on my system. As long as you don’t wipe the entire hard disk you should be able to dual boot as well. Partitioning the SSD should be no different ( I have never used an SSD so don’t quote me on this).
Here is a guide on the Arch Wiki for a similar Lenovo model/ It has similar enough hardware to the Asus and the u410. Hopefully between the two guides you can find your answers.
https://wiki.archlinux.org/index.php/Lenovo_IdeaPad_Y580
Great! Thanks, will give it a shot.
Hi. First thx for the useful guide.
But I got some trouble when boot.
If I do not use ‘nomodeset’ parameter to launch the kernel,
I’ll got a blackscreen after waiting for udev events.
But ‘nomodeset’ means that I have to use vesa driver to get poor performance.
How can I solve it?