| 1 | = Xen GPU Cluster Practice = |
| 2 | == 實作三: 在虛擬機器上獲得 GPU 硬體加速 - 使用VMGL == |
| 3 | |
| 4 | == 步驟一: 在 Dom0 上安裝 VMGL == |
| 5 | '''# 安裝環境所需套件.''' [[BR]] |
| 6 | rider@cloud:~/vmgl$ sudo apt-get install build-essential mesa-common-dev libglu1-mesa-dev mesa-utils libxmu-headers libxmu6 libxmu-dev zlib1g-dev libjpeg62 libjpeg62-dev xutils-dev libxaw-headers libxaw7 libxaw7-dev libxext6 libxext-dev rxvt lwm xauth xvfb xfonts-100dpi xfonts-75dpi culmus xfonts-scalable xfonts-base [[BR]] |
| 7 | '''# 下載VMGL.''' [[BR]] |
| 8 | rider@cloud:~/vmgl$ wget http://www.cs.toronto.edu/~andreslc/software/vmgl-0.1.tar.bz2 [[BR]] |
| 9 | rider@cloud:~/vmgl$ tar jxvf vmgl-0.1.tar.bz2 [[BR]] |
| 10 | rider@cloud:~/vmgl$ cd ./vmgl.hg/tightvnc/ [[BR]] |
| 11 | '''# Patch for AMD64_Machine.''' [[BR]] |
| 12 | rider@cloud:~/vmgl/vmgl.hg/tightvnc$ patch -p0 < ../../tightvnc-1.2.9-amd64support.patch [[BR]] |
| 13 | rider@cloud:~/vmgl$ cd .. [[BR]] |
| 14 | '''# 設定編譯器路徑.''' [[BR]] |
| 15 | rider@cloud:~/vmgl$ sudo ln -sf /usr/bin/make /usr/bin/gmake (if necessary) [[BR]] |
| 16 | '''# 編譯.''' [[BR]] |
| 17 | rider@cloud:~/vmgl/vmgl.hg$ make -j 4 [[BR]] |
| 18 | '''# 安裝於 Dom0(host) 端上.''' [[BR]] |
| 19 | rider@cloud:~/vmgl/vmgl.hg$ sudo make install-host [[BR]] |
| 20 | '''# 設定主機信任清單.''' [[BR]] |
| 21 | rider@cloud:~$ xauth [[BR]] |
| 22 | {{{ |
| 23 | # Set the authority for remote guest. |
| 24 | |
| 25 | Using authority file /home/rider/.Xauthority |
| 26 | xauth> add guest/unix:10 MIT-MAGIC-COOKIE-1 ec0ffd387888b9749d55f88031505888 |
| 27 | xauth> add guest/unix:1 MIT-MAGIC-COOKIE-1 6824789b4ce0ac5743aeb57fd3ef8f5b |
| 28 | xauth> exit |
| 29 | }}} |
| 30 | |
| 31 | == 步驟二: 建構一台 VMGL Guest VM == |
| 32 | '''# 設定你想要怎樣規格的虛擬機器.''' |
| 33 | rider@cloud:~$ sudo vim /etc/xen-tools/xen-tools.conf [[BR]] |
| 34 | {{{ |
| 35 | dir = /home |
| 36 | install-method = debootstrap |
| 37 | size = 8Gb # Disk image size. |
| 38 | memory = 1024Mb # Memory size |
| 39 | swap = 128Mb # Swap size |
| 40 | fs = ext3 # use the EXT3 filesystem for the disk image. |
| 41 | dist = hardy # Default distribution to install. ---> For CUDA Support (Ubuntu 8.0.4) |
| 42 | image = sparse # Specify sparse vs. full disk images. |
| 43 | gateway = 140.XXX.XXX.XXX |
| 44 | netmask = 255.255.255.0 |
| 45 | broadcast = 140.XXX.XXX.XXX |
| 46 | kernel = /boot/vmlinuz-`uname -r` |
| 47 | initrd = /boot/initrd.img-`uname -r` |
| 48 | mirror = http://gb.archive.ubuntu.com/ubuntu/ |
| 49 | ext3_options = noatime,nodiratime,errors=remount-ro |
| 50 | ext2_options = noatime,nodiratime,errors=remount-ro |
| 51 | xfs_options = defaults |
| 52 | reiser_options = defaults |
| 53 | }}} |
| 54 | rider@cloud:~$ sudo xen-create-image --hostname guest --ip 140.XXX.XXX.XXX [[BR]] |
| 55 | |
| 56 | == 步驟三: 設定虛擬機器(Guest) == |
| 57 | rider@cloud:~$ sudo vim /etc/xen/nvidia.cfg [[BR]] |
| 58 | {{{ |
| 59 | kernel = '/boot/vmlinuz-2.6.22.9' |
| 60 | ramdisk = '/boot/initrd.img-2.6.22.9' |
| 61 | |
| 62 | memory = '1024' |
| 63 | vcpus = '4' |
| 64 | |
| 65 | # 不需配置 PCIE 顯示卡 |
| 66 | # pci = ['01:00.0'] |
| 67 | |
| 68 | root = '/dev/sda2 ro' |
| 69 | disk = [ |
| 70 | 'file:/home/domains/nvidia/disk.img,sda2,w', |
| 71 | 'file:/home/domains/nvidia/swap.img,sda1,w', |
| 72 | ] |
| 73 | name = 'nvidia' |
| 74 | |
| 75 | # |
| 76 | # Networking |
| 77 | # |
| 78 | vif = [ 'ip=140.xxx.xxx.xxx,mac=00:16:3E:AA:70:5C' ] |
| 79 | |
| 80 | # |
| 81 | # Behaviour |
| 82 | # |
| 83 | on_poweroff = 'destroy' |
| 84 | on_reboot = 'restart' |
| 85 | on_crash = 'restart' |
| 86 | }}} |
| 87 | |
| 88 | == 步驟四: 在 DomU(Guest) 上安裝 VMGL == |
| 89 | '''# 啟動虛擬機器Guest並登入.''' [[BR]] |
| 90 | '''# 方法一.''' [[BR]] |
| 91 | rider@cloud:~$ sudo xm create -c guest.cfg [[BR]] |
| 92 | '''# 方法二.''' [[BR]] |
| 93 | @Dom0 |
| 94 | rider@cloud:~$ sudo xm create guest.cfg [[BR]] |
| 95 | @!UserSide |
| 96 | rider@PC:~$ ssh 140.xxx.xxx.xxx [[BR]] |
| 97 | '''# 安裝環境所需套件.''' [[BR]] |
| 98 | rider@guest:~$ mkdir -p vmgl [[BR]] |
| 99 | rider@guest:~$ cd ./vmgl [[BR]] |
| 100 | rider@guest:~/vmgl$ sudo apt-get install build-essential mesa-common-dev libglu1-mesa-dev mesa-utils libxmu-headers libxmu6 libxmu-dev zlib1g-dev libjpeg62 libjpeg62-dev xutils-dev libxaw-headers libxaw7 libxaw7-dev libxext6 libxext-dev rxvt lwm xauth xvfb xfonts-100dpi xfonts-75dpi culmus xfonts-scalable xfonts-base [[BR]] |
| 101 | '''# 基本桌面環境.''' [[BR]] |
| 102 | {{{ |
| 103 | # Desgin for lightweight basic windows support |
| 104 | |
| 105 | xfonts-base xfonts-100dpi xfonts-75dpi -> fonts support |
| 106 | rxvt -> x-terminal-emulator for VNC |
| 107 | lwm -> x-window-manager for VNC |
| 108 | }}} |
| 109 | '''# 下載VMGL.''' [[BR]] |
| 110 | rider@guest:~/vmgl$ wget http://www.cs.toronto.edu/~andreslc/software/vmgl-0.1.tar.bz2 [[BR]] |
| 111 | rider@guest:~/vmgl$ tar jxvf vmgl-0.1.tar.bz2 [[BR]] |
| 112 | rider@guest:~/vmgl$ cd ./vmgl.hg/tightvnc/ [[BR]] |
| 113 | '''# Patch for AMD64_Machine.''' [[BR]] |
| 114 | rider@guest:~/vmgl/vmgl.hg/tightvnc$ patch -p0 < ../../tightvnc-1.2.9-amd64support.patch [[BR]] |
| 115 | rider@guest:~/vmgl$ cd .. [[BR]] |
| 116 | '''# 設定編譯器路徑.''' [[BR]] |
| 117 | rider@guest:~/vmgl$ sudo ln -sf /usr/bin/make /usr/bin/gmake (if necessary) [[BR]] |
| 118 | '''# 建立安裝所需基本目錄.''' [[BR]] |
| 119 | rider@guest:~/vmgl/vmgl.hg$ sudo mkdir -p /usr/lib/xorg (if necessary) [[BR]] |
| 120 | rider@guest:~/vmgl/vmgl.hg$ sudo mkdir -p /usr/lib/xorg/modules (if necessary) [[BR]] |
| 121 | rider@guest:~/vmgl/vmgl.hg$ sudo mkdir -p /usr/lib/xorg/modules/extensions (if necessary) [[BR]] |
| 122 | '''# 編譯.''' [[BR]] |
| 123 | rider@guest:~/vmgl/vmgl.hg$ make [[BR]] |
| 124 | '''# 安裝於 DomU(guest) 端上.''' [[BR]] |
| 125 | rider@guest:~/vmgl/vmgl.hg$ sudo make install-guest [[BR]] |
| 126 | '''# 修正 rgb PATH 問題.''' [[BR]] |
| 127 | {{{ |
| 128 | ## Fix the rgb_Path problem. |
| 129 | rider@guest:~/vmgl/vmgl.hg$ sudo mkdir -p /usr/X11R6/lib |
| 130 | rider@guest:~/vmgl/vmgl.hg$ sudo mkdir /usr/X11R6/lib/X11 |
| 131 | rider@guest:~/vmgl/vmgl.hg$ sudo ln -sf /etc/X11/rgb.txt /usr/X11R6/lib/X11/rgb |
| 132 | }}} |