UbuntuServer16.04でnvidia-dockerを動かす
UbuntuServer16.04でnvidia-dockerを動かす
構成
- UbuntuServer 16.04.4 LTS
- GTX1080ti *1
確認
以下のコマンドで,何も出てこないことを確認する
$ sudo dpkg -l | grep nvidia $ sudo dpkg -l | grep cuda
Nvidiaドライバのインストール
リポジトリ(Proprietary GPU Drivers : “Graphics Drivers” team)
を登録して,ドライバをインストールする
$ sudo add-apt-repository ppa:graphics-drivers/ppa $ sudo apt update $ sudo apt -y install nvidia-396
再起動し,
$ sudo reboot
GPUが認識されているかを確認
$ nvidia-smi +-----------------------------------------------------------------------------+ | NVIDIA-SMI 396.18 Driver Version: 396.18 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 108... Off | 00000000:41:00.0 On | N/A | | 29% 43C P0 59W / 250W | 59MiB / 11164MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1594 G /usr/lib/xorg/Xorg 56MiB | +-----------------------------------------------------------------------------+
dockerのインストール
Ubuntu公式リポジトリのdocker.io
ではnvidia-docker
を実行できない
(docker-engine
, docker-ce
, docker-ee
のいずれかのパッケージが依存関係として必要)
ので、Get Docker CE for Ubuntu | Docker Documentation
の通りにインストールする
$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo apt-key fingerprint 0EBFCD88 $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" $ sudo apt-get update $ sudo apt-get -y install docker-ce
ユーザをdocker
グループに追加し、ログインし直すとsudo
無しでdockerを実行できるようになる
$ sudo gpasswd -a ユーザ名 docker ## logout & login $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE
nvidia-dockerのインストール
GitHub - NVIDIA/nvidia-docker: Build and run Docker containers leveraging NVIDIA GPUsの通りにインストールする
GPGキーの追加
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
リポジトリの追加
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) $ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list $ sudo apt-get update
nvidia-docker
のインストール
$ sudo apt-get -y install nvidia-docker2 $ sudo pkill -SIGHUP dockerd
テスト
$ docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi Unable to find image 'nvidia/cuda:latest' locally latest: Pulling from nvidia/cuda d3938036b19c: Pull complete a9b30c108bda: Pull complete 67de21feec18: Pull complete 817da545be2b: Pull complete d967c497ce23: Pull complete 5ddeb439bad8: Pull complete c6496427ad3b: Pull complete 360fde1360ca: Pull complete 4cc434a95aa2: Pull complete e5c0eee6e0d5: Pull complete Digest: sha256:d17a4683f1554de305741e55886d5835b204f602ca73a0df83e02afeb313db76 Status: Downloaded newer image for nvidia/cuda:latest Thu Apr 19 08:35:27 2018 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 396.18 Driver Version: 396.18 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 108... Off | 00000000:41:00.0 On | N/A | | 29% 32C P8 10W / 250W | 59MiB / 11164MiB | 1% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| +-----------------------------------------------------------------------------+
動いた
Debian9にGeForceのドライバをインストールする
- NvidiaGraphicsDrivers - Debian Wikiに載っている通りにすれば問題なくインストールできた
- GTX1080ti*1, GUI無しの環境で下記を実行
リポジトリの追加
$ sudo vim /etc/apt/sources.list deb http://httpredir.debian.org/debian/ stretch main contrib non-free
インストール
$ sudo apt update $ sudo apt -y install linux-headers-$(uname -r|sed 's/[^-]*-[^-]*-//') nvidia-driver
この段階ではまだ有効になっていないので、再起動してnouveau
のblacklistを適用する必要がある
$ sudo reboot
その他
$ sudo apt -y install nvidia-smi $ nvidia-smi +-----------------------------------------------------------------------------+ | NVIDIA-SMI 375.82 Driver Version: 375.82 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 108... Off | 0000:41:00.0 Off | N/A | | 29% 43C P0 59W / 250W | 0MiB / 11158MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+
動いてそう
Debian9をX2Goサーバーにする
Xfceのインストール
GUI環境がインストールされていないのでXfceをインストールする
$ sudo apt -y install --no-install-recommends task-xfce-desktop
dirmngrのインストール
X2Goインストール時に
gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
と言われるので、dirmngrをインストールしておく
$ sudo apt -y install dirmngr
X2Goサーバのインストール
wiki:repositories:debian [X2Go - everywhere@home]に載っている通りGPGキー、リポジトリを追加
$ apt-key adv --recv-keys --keyserver keys.gnupg.net E1F958385BFE2B6E Executing: /tmp/apt-key-gpghome.5cBT7DkF8w/gpg.1.sh --recv-keys --keyserver keys.gnupg.net E1F958385BFE2B6E gpg: key E1F958385BFE2B6E: public key "X2go Debian/Ubuntu Packaging <debian@x2go.org>" imported gpg: Total number processed: 1 gpg: imported: 1 $ sudo bash -c "echo 'deb http://packages.x2go.org/debian stretch extras main' >> /etc/apt/sources.list.d/x2go.list" $ cat /etc/apt/sources.list.d/x2go.list deb http://packages.x2go.org/debian stretch extras main
aptのキャッシュの更新
$ sudo apt update $ sudo apt install x2go-keyring $ sudo apt update
X2Go本体のインストール
$ sudo apt -y install x2goserver x2goserver-xsession
X2Goクライアントのインストール
Windows10にインストールする
doc:installation:x2goclient [X2Go - everywhere@home]のリンクDownload X2Go for MS Windowsからexeをダウンロードしてインストール
インストールが完了したら
- Host: サーバのIP
- Login: SSHログインするユーザ名
を指定して、Session type
をXFCEにすればとりあえず接続できた
references
matplotlibでNimbus Roman No9 Lを使う
でグラフの文字をNimbus Roman No9 L
にしたい
フォントのインストール
$ sudo apt -y install fonts-texgyre
使用するコード
test.mplstyle
は空のテキスト
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt with plt.style.context('test.mplstyle'): x = np.linspace(0,3,20) y = x**2 + 1 plt.plot(x, y, "r-") plt.xlabel("x") plt.ylabel("y") plt.savefig("test.pdf")
プロットしてみる
この時点ではフォント設定を変更していないのでデフォルトのフォントが使用される
$ python3 plot.py $ pdffonts test.pdf name type encoding emb sub uni object ID ------------------------------------ ----------------- ---------------- --- --- --- --------- DejaVuSans Type 3 Custom yes no no 14 0
フォントを変える
font.serifにNimbus Roman No9 L
を指定
$ vim test.mplstyle font.serif : Nimbus Roman No9 L font.family : serif
して実行
$ python3 plot.py ... UserWarning: findfont: Font family ['serif'] not found. Falling back to DejaVu Sans ... $ pdffonts test.pdf name type encoding emb sub uni object ID ------------------------------------ ----------------- ---------------- --- --- --- --------- DejaVuSans Type 3 Custom yes no no 14 0
serif
が見つからないらしい
font.familyに直接フォントを指定
$ vim test.mplstyle font.family : Nimbus Roman No9 L
して実行
$ python3 plot.py ... UserWarning: findfont: Font family ['Nimbus Roman No9 L'] not found. Falling back to DejaVu Sans ... $ pdffonts test.pdf name type encoding emb sub uni object ID ------------------------------------ ----------------- ---------------- --- --- --- --------- DejaVuSans Type 3 Custom yes no no 14 0
Nimbus Roman No9 L
が見つからない
Nimbus Roman No9 Lはインストールされているのか確認
インストールはされている
$ fc-list | grep Nimbus /usr/share/fonts/type1/gsfonts/n021024l.pfb: Nimbus Roman No9 L:style=Medium Italic /usr/share/fonts/type1/gsfonts/n021004l.pfb: Nimbus Roman No9 L:style=Medium /usr/share/fonts/type1/gsfonts/n022003l.pfb: Nimbus Mono L:style=Regular /usr/share/fonts/type1/gsfonts/n021023l.pfb: Nimbus Roman No9 L:style=Regular Italic /usr/share/fonts/type1/gsfonts/n019063l.pfb: Nimbus Sans L:style=Regular Condensed Italic /usr/share/fonts/type1/gsfonts/n019064l.pfb: Nimbus Sans L:style=Bold Condensed Italic /usr/share/fonts/type1/gsfonts/n022023l.pfb: Nimbus Mono L:style=Regular Oblique /usr/share/fonts/type1/gsfonts/n019043l.pfb: Nimbus Sans L:style=Regular Condensed /usr/share/fonts/type1/gsfonts/n019044l.pfb: Nimbus Sans L:style=Bold Condensed /usr/share/fonts/type1/gsfonts/n021003l.pfb: Nimbus Roman No9 L:style=Regular /usr/share/fonts/type1/gsfonts/n019023l.pfb: Nimbus Sans L:style=Regular Italic /usr/share/fonts/type1/gsfonts/n022004l.pfb: Nimbus Mono L:style=Bold /usr/share/fonts/type1/gsfonts/n019024l.pfb: Nimbus Sans L:style=Bold Italic /usr/share/fonts/type1/gsfonts/n019004l.pfb: Nimbus Sans L:style=Bold /usr/share/fonts/type1/gsfonts/n022024l.pfb: Nimbus Mono L:style=Bold Oblique /usr/share/fonts/type1/gsfonts/n019003l.pfb: Nimbus Sans L:style=Regular
matplotlibのキャッシュを削除
$ rm -rf ~/.cache/matplotlib
ここでもう一度プロットするもNimbus Roman No9 L
が見つからない
$ python3 plot.py ... UserWarning: findfont: Font family ['Nimbus Roman No9 L'] not found. Falling back to DejaVu Sans ... $ pdffonts test.pdf name type encoding emb sub uni object ID ------------------------------------ ----------------- ---------------- --- --- --- --------- DejaVuSans Type 3 Custom yes no no 14 0
texモードをONにする
$ vim test.mplstyle text.usetex : true font.serif : Nimbus Roman No9 L font.family : serif
DejaVuではなくなったが、Nimbus Romanでもない
$ python3 plot.py ... UserWarning: findfont: Font family ['Nimbus Roman No9 L'] not found. Falling back to DejaVu Sans ... $ pdffonts test.pdf name type encoding emb sub uni object ID ------------------------------------ ----------------- ---------------- --- --- --- --------- CMMI10 Type 1 Builtin yes no no 17 0 CMR10 Type 1 Builtin yes no no 13 0
なんとなくTimesにしてみたら
$ vim test.mplstyle text.usetex : true font.serif : Times font.family : serif
縦軸、横軸の文字(x
、y
)がNimbus Romanになった
$ python3 plot.py $ pdffonts test.pdf name type encoding emb sub uni object ID ------------------------------------ ----------------- ---------------- --- --- --- --------- CMMI10 Type 1 Builtin yes no no 17 0 NimbusRomNo9L-Regu Type 1 Custom yes no no 13 0
texモードをOFFにする
$ vim test.mplstyle text.usetex : false font.family : Times
DejaVu
$ python3 plot.py ... UserWarning: findfont: Font family ['Nimbus Roman No9 L'] not found. Falling back to DejaVu Sans ... name type encoding emb sub uni object ID ------------------------------------ ----------------- ---------------- --- --- --- --------- DejaVuSans Type 3 Custom yes no no 14 0
まとめ
matplotlibでNimbus Roman No9 Lを使用するときは
fonts-texgyre
をインストールして、matplotlibのフォント設定を
text.usetex : true font.serif : Times font.family : serif
にする
Ubuntu16.04でのbondingとWake on Lanの設定
NIC冗長化
設定前
eno1
の方のIPを固定してそっちを使ってる
$ sudo nmcli device DEVICE TYPE STATE CONNECTION eno1 ethernet connected eno1 enp14s0 ethernet disconnected -- lo loopback unmanaged --
設定
bondingデバイスの作成
$ sudo nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup Connection 'bond0' (d1619bdf-38b7-4f20-8a0d-fa9f419951ad) successfully added. $ nmcli connection show NAME UUID TYPE DEVICE eno1 bcd81468-59c2-401e-bfb8-33b23c2b7d57 802-3-ethernet eno1 bond0 d1619bdf-38b7-4f20-8a0d-fa9f419951ad bond --
enp14s0
をスレーブに追加する
$ sudo nmcli connection add type bond-slave ifname enp14s0 master bond0 Connection 'bond-slave-enp14s0' (3405d7d6-6e5a-4f8f-82c9-f4c386feae85) successfully added. $ nmcli connection show NAME UUID TYPE DEVICE eno1 bcd81468-59c2-401e-bfb8-33b23c2b7d57 802-3-ethernet eno1 bond-slave-enp14s0 3405d7d6-6e5a-4f8f-82c9-f4c386feae85 802-3-ethernet -- bond0 d1619bdf-38b7-4f20-8a0d-fa9f419951ad bond --
bond0
の設定
$ sudo nmcli connection modify bond0 ipv4.addresses 192.168.1.12/24 $ sudo nmcli connection modify bond0 ipv4.method manual $ sudo nmcli connection modify bond0 ipv4.gateway 192.168.1.1 $ sudo nmcli connection modify bond0 ipv4.dns 192.168.1.1
enp14s0
だけをつないだbond0
を起動する
$ sudo nmcli connection modify bond-slave-enp14s0 connection.autoconnect yes $ sudo nmcli connection modify bond0 connection.autoconnect yes $ sudo nmcli connection up bond0
これで,bond0を使ってSSH等で接続できるようになったのでeno1
も追加する
$ sudo nmcli connection delete eno1 $ sudo nmcli connection add type bond-slave ifname eno1 master bond0 $ sudo nmcli connection modify bond-slave-eno1 connection.autoconnect yes $ sudo nmcli connection down bond0 && sudo nmcli connection up bond0
接続状態を確認する
$ cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: eno1 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eno1 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 38:d5:47:c7:c0:ad Slave queue ID: 0 Slave Interface: enp14s0 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 38:d5:47:c7:c0:ae Slave queue ID: 0
Wake on Lan
Wake on Lanは実デバイス(eno1
,enp14s0
)で有効になっている必要がある
以下のように1 (default)
となっていれば何も設定する必要はない
$ nmcli -f "802-3-ethernet.wake-on-lan" con show bond-slave-eno1 802-3-ethernet.wake-on-lan: 1 (default)
MACアドレスを調べる
$ nmcli -f "GENERAL.HWADDR" device show eno1 GENERAL.HWADDR: 38:D5:47:C7:C0:AD
enp14s0
で調べても同じMACアドレスが表示された.
本当は38:d5:47:c7:c0:ae
のはずなので,bodingしていることと関係がある?
$ nmcli -f "GENERAL.HWADDR" device show enp14s0 GENERAL.HWADDR: 38:D5:47:C7:C0:AD
とりあえずeno1
でWake on Lanができれば良いことにしておく
これで,クライアントから以下のコマンドを実行すれば起動できる
$ sudo ether-wake -i eno1 38:D5:47:C7:C0:AD
もし起動できない場合はUEFIでWake by PCIe
みたいな項目をEnableにする
Ryzen5 1600にArch Linuxをインストールする
構成
項目 | 型番 |
---|---|
CPU | AMD Ryzen5 1600 |
M/B | MSI TOMAHAWK B350 |
RAM | SanMax SMD4-U8GM-24R-D |
サウンド | Onkyo SE200PCI |
Install
インストールガイド - ArchWikiに全部書いてあるので,コマンドのみ
$ ls /sys/firmware/efi/efivars $ loadkeys jp106 ... $ parted /dev/sda (parted)$ mklabel gpt (parted)$ mkpart ESP fat32 1MiB 513MiB (parted)$ set 1 boot on (parted)$ mkpart primary xfs 513MiB 100% (parted)$ print Number Start End Size File system Name Flags 1 1049kB 538MB 537MB fat32 boot, esp 2 538MB 120GB 119GB xfs (parted)$ quit $ mkfs.fat -F32 /dev/sda1 $ mkfs.xfs /dev/sda2 $ mount /dev/sda2 /mnt $ mkdir /mnt/boot $ mount /dev/sda1 /mnt/boot $ ping archlinuxjp.org ...ok $ timedatectl set-ntp true $ vim /etc/pacman.d/mirrorlist ## Japan http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/$repo/os/$arch http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch $ pacstrap /mnt base base-devel $ genfstab -U /mnt >> /mnt/etc/fstab $ arch-chroot /mnt $ ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime $ hwclock --systohc --utc $ pacman -S vim $ vim /etc/locale.gen en_US.UTF-8 UTF-8 ja_JP.UTF-8 UTF-8 $ locale-gen Generating locales... en_US.UTF-8... done ja_JP.UTF-8... done Generation complete. $ echo LANG=en_US.UTF-8 > /etc/locale.conf $ echo KEYMAP=jp106 > /etc/vconsole.conf $ echo ホスト名 > /etc/hostname $ vim /etc/hosts 127.0.1.1 ホスト名.localdomain ホスト名 $ mkinitcpio -p linux $ passwd $ ls /sys/firmware/efi/efivars ... $ bootctl --path=/boot Install $ vim /boot/loader/loader.conf default arch timeout 3 editor 0 $ blkid -s PARTUUID -o value /dev/sda2 UUID文字列 $ vim /boot/loader/entries/arch.conf title Arch Linux linux /vmlinuz-linux initrd /initramfs-linux.img options root=PARTUUID=UUID文字列 rw $ exit $ umount -R /mnt $ reboot
初期設定
ユーザ追加・sudo有効化
$ useradd ユーザ名 $ gpasswd -a ユーザ名 wheel $ passwd ユーザ名 $ pacman -S sudo $ EDITOR=vim visudo %wheel ALL=(ALL) ALL # コメント解除する
これ以降はユーザ権限で設定を行う
DHCP有効化
デフォルトで起動しているものと思っていたが,起動していなかったので
$ sudo systemctl start dhcpcd
yaourt
$ sudo vim /etc/pacman.conf [archlinuxfr] SigLevel = Never Server = http://repo.archlinux.fr/$arch $ sudo pacman --sync --refresh yaourt
Xorg
あたりを参考に
$ pacman -S xorg-server xorg-server-utils xorg-xinit xorg-xclock xterm $ lspci | grep -e VGA -e 3D 25:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde PRO [Radeon HD 7750/8740 / R7 250E] $ sudo pacman -S xf86-video-amdgpu
グラフィックドライバをロードするために,再起動する
$ reboot
Xfce
$ sudo pacman -S xfce4 xfce4-goodies gamin $ vim ~/.xinitrc #!/bin/bash exec startxfce4
キーボードレイアウトの設定
$ sudo vim /etc/X11/xorg.conf.d/00-keyboard.conf Section "InputClass" Identifier "system-keyboard" MatchIsKeyboard "on" Option "XkbLayout" "jp,us" Option "XkbModel" "pc106" Option "XkbVariant" ",dvorak" Option "XkbOptions" "grp:alt_shift_toggle" EndSection $ sudo reboot
日本語入力
$ sudo pacman -S fcitx-mozc fcitx-im fcitx-configtool $ vim ~/.xprofile export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS=”@im=fcitx” $ vim ~/.xinitrc [ -f /etc/xprofile ] && . /etc/xprofile [ -f ~/.xprofile ] && . ~/.xprofile fcitx-autostart & $ sudo reboot
ALSAの設定
alsa-utils
のインストール
$ sudo pacman -S alsa-utils
デバイスの確認
サウンドボード(ice1724
)から音を鳴らしたい
$ alsamixer カード: ONKYO SE200PCI F1: ヘルプ チップ: ICE1724 - multitrack F2: システム情報 表示: F3:[再生] F4: 録音 F5: 全て F6: サウンドカード選択 項目: Front [dBゲイン: -18.00, -18.00] Esc: 終了
ロードされているモジュールを確認する
$ cat /proc/asound/modules 0 snd_hda_intel 1 snd_hda_intel 2 snd_ice1724
おそらく
snd_ice1724をデフォルト(0)のデバイスに設定する
UEFIでオンボードを無効化(Disable)し、以下のファイルで読み込み順を指定する
$ sudo vim /etc/modprobe.d/alsa-base.conf options snd slots=snd_ice1724,snd_hda_intel options snd_ice1724 index=0 options snd_hda_intel index=1
再起動後,
$ cat /proc/asound/modules 0 snd_ice1724 1 snd_hda_intel
となり,無事に再生できた.
一応,失敗した設定例も下に乗せておく.
失敗1:snd_ice1724
をデフォルト(0)に固定する
オンボードを有効にした状態
$ cat /proc/asound/modules 0 snd_hda_intel 1 snd_hda_intel 2 snd_ice1724
では,snd_hda_intel
が2つ存在し,
$ sudo vim /etc/modprobe.d/alsa-base.conf options snd slots=snd_ice1724,snd_hda_intel options snd_ice1724 index=0 options snd_hda_intel index=1
や
$ sudo vim /etc/modprobe.d/alsa-base.conf options snd slots=snd_ice1724,snd_hda_intel,snd_hda_intel options snd_ice1724 index=0 options snd_hda_intel index=1 options snd_hda_intel index=2
等を設定してもsnd_ice1724
がデフォルトにならなかった
失敗2:環境変数を使ってデフォルトPCMを選択する
Select the default PCM via environment variable - ArchWikiの通りに設定するとice1724
から音が出るようになったが複数同時再生(Firefox+SMPlayer)ができなかった
$ sudo vim /etc/asound.conf pcm.!default { type plug slave.pcm { @func getenv vars [ ALSAPCM ] default "hw:2,0" } }
ここで,hw:2,0
は
$ aplay -l カード 2: SE200PCI [ONKYO SE200PCI], デバイス 0: ICE1724 [ICE1724] サブデバイス: 0/1 サブデバイス #0: subdevice #0
でしらべた
失敗3:~/.asoundrc
でデバイスを指定する
Alternative method - ArchWiki の通りに設定した場合も同時再生ができなかった
この設定では,はじめに音声再生を始めたソフトがハードウェアがデバイスを専有してしまうため同時再生できないらしい.
$ vim ~/.asoundrc pcm.!default { type hw card 2 } ctl.!default { type hw card 2 }
renameコマンドでファイルをリネームする
Ubuntuのrename
コマンドが正規表現を使ってファイルをリネームするとは違っていたのでメモ
使い方
$ rename <expression> <replacement> <file>...
なので
拡張子変更
$ ls aaa.sh abc.sh sh_script.txt $ rename .sh .txt *.sh $ ls aaa.txt abc.txt sh_script.txt
最初の1つしか置換されないので注意が必要
$ ls aaa.sh.sh $ rename .sh .txt aaa.sh.sh $ ls aaa.txt.sh
文字列の削除
空の文字列(''
)で置換する
$ ls aaa_bak.sh $ rename _bak '' aaa_bak.sh $ ls aaa.sh
prefixの追加
正規表現が使えないのでファイル名にprefixを追加したい場合はls
を用いて
$ ls aaa.sh aaa_sh.txt $ ls /path/to/dir/* /path/to/dir/aaa.sh /path/to/dir/aaa_sh.txt $ rename /path/to/dir/ /path/to/dir/prefix_ $(ls /path/to/dir/*) $ ls /path/to/dir/ /path/to/dir/prefix_aaa.sh /path/to/dir/prefix_aaa_sh.txt
するしかない??