4
Install CentOS 7 in an LXC/LXD container on an NVIDIA Xavier
source link: https://gist.github.com/fwyzard/f5a24c50dee91113f07d265e404fdae4
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Install and configure LXD
Install LXD
sudo snap install lxd
Perform the initial configuration
sudo lxd init
The defaults are mostly fine, but I used a dir
storage backend for simplicity:
Would you like to use LXD clustering? (yes/no) [default=no]: no
Do you want to configure a new storage pool? (yes/no) [default=yes]: yes
Name of the new storage pool [default=default]: default
Name of the storage backend to use (btrfs, ceph, dir, lvm) [default=btrfs]: dir
Would you like to connect to a MAAS server? (yes/no) [default=no]: no
Would you like to create a new local network bridge? (yes/no) [default=yes]: yes
What should the new bridge be called? [default=lxdbr0]: lxdbr0
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: auto
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: auto
Would you like LXD to be available over the network? (yes/no) [default=no]: no
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]: yes
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: no
Install and configure a CentOS 7 image
Create and launch a CentOS 7 image
sudo lxc launch images:centos/7/arm64 centos
Configure the container as privileged
Note: this should not be necessary, but it is the only way I have found to get ping
and raw sockets to work
sudo lxc config set centos security.privileged true
sudo lxc restart centos
Optionally, set the container timezone
sudo lxc exec centos -- /bin/ln -sf $(readlink /etc/localtime) /etc/localtime
Configure the container for CUDA
Make the NVIDIA devices available from the host
Note: the device list comes from https://github.com/Technica-Corporation/Tegra-Docker#simple-gpu-docker-image
DEVICES="/dev/nvmap /dev/nvhost-ctrl /dev/nvhost-ctrl-gpu /dev/nvhost-prof-gpu /dev/nvhost-gpu /dev/nvhost-as-gpu"
for DEVICE in $DEVICES; do
sudo lxc config device add centos $DEVICE unix-char path=$DEVICE
done
sudo lxc exec centos -- chmod a+rw $DEVICES
sudo lxc exec centos -- bash -c "echo -e \"\n# make NVIDIA devices accessible to all users\nchmod a+rw $DEVICES\" >> /etc/rc.local"
Make the host CUDA and TEGRA libraries available to the container
sudo lxc config device add centos cuda-10.0 disk source=/usr/local/cuda-10.0 path=/usr/local/cuda-10.0
sudo lxc exec centos -- ln -s cuda-10.0 /usr/local/cuda
echo /usr/local/cuda-10.0/targets/aarch64-linux/lib | sudo lxc exec centos -- tee /etc/ld.so.conf.d/cuda-10-0.conf
sudo lxc config device add centos nvidia-tegra disk source=/usr/lib/aarch64-linux-gnu/tegra path=/usr/lib64/tegra
sudo lxc exec centos -- ln -s tegra/libcuda.so /usr/lib64/libcuda.so
echo /usr/lib64/tegra | sudo lxc exec centos -- tee /etc/ld.so.conf.d/nvidia-tegra.conf
sudo lxc exec centos -- ldconfig
Final steps
Optionally, add useful packages and the EPEL (Extra Packages for Enterprise Linux) repository
sudo lxc exec centos -- /bin/bash
yum -y update
# install a glut library (used by the CUDA samples)
yum -y install freeglut freeglut-devel
# install varius usefulpackages
yum -y install sudo vim wget rsync krb5-workstation xauth git subversion bash-completion \
mlocate screen zip unzip readline-devel python-devel bc finger tcl-devel tk-devel
# add the EPEL (Extra Packages for Enterprise Linux) repository
yum -y install epel-release
updatedb
exit
Reboot
sudo reboot
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK