HARK on WSL2

関係者向け
For interested parties

注意:このページの情報はオフィシャルにサポートしていない情報を掲載していますので 非公開 です。
Note: The information on this page is NOT publicly available as it contains information that is not officially supported.


このページでは WSL2 上で動作させるためのノウハウを掲載します。ただし、環境によっては動作しない場合もございますので サポート対象外 とさせていただきます。 このページには、Microsoft または Canonical によって正式にサポートされていない情報が含まれています。
This page provides know-how for operating on WSL2. However, we do NOT support it as it may not work depending on the environment. This page contains information that is not officially supported by Microsoft or Canonical.



WSL2上でオーディオデバイスを動作させる方法
How to make audio devices work on WSL2

最初に最新版のWSL2にアップグレードする必要があります。PowerShellやWindowsTerminalなどで以下のコマンドを実行します。
起動中のすべてのディストリビューションが停止しますのでご注意ください。
You must first upgrade to the latest version of WSL2. Execute following command using PowerShell or Windows Terminal.
Please note that all running distributions will be stopped.

PS C:\Users\USER> wsl --update
更新プログラムを確認しています。
Linux 用 Windows サブシステムをバージョンに更新しています: 2.x.y。
PS C:\Users\USER> wsl --update
更新プログラムを確認しています。
Linux 用 Windows サブシステムの最新バージョンは既にインストールされています。

次にUbuntuディストリビューションを起動し、下記のパッケージをインストールします。
Next, start the Ubuntu distribution and install the following packages.

$ sudo apt install apt-utils pulseaudio

インストールが完了した場合、下記のコマンドで状態を確認します。注目する箇所は、 arecord -l でサウンドカードが見つからないという結果と arecord -L でデバイスの defaultPulseAudio sound server になっていることです。
When the installation is complete, check the status with the command below. The points to note are that arecord -l shows that no sound card is found, and arecord -L shows that the device defaults to PulseAudio sound server .

$ arecord -l
arecord: device_list:274: サウンドカードが見つかりません...
$ arecord -L
null
    Discard all samples (playback) or generate zero samples (capture)
default
    Playback/recording through the PulseAudio sound server
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization

録音する場合はデバイス指定を行わない、または default を指定してください。下記はマイクアレイデバイス TAMAGO-03 を使用した場合の例です。
When recording, please do not specify the device or specify default. The following is an example when using the microphone array device TAMAGO-03.

$ arecord -r 16000 -c 8 -f S24_3LE tamago_rec.wav
録音中 WAVE 'tamago_rec.wav' : Signed 24 bit Little Endian in 3bytes, レート 16000 Hz, チャネル数 8
^Cシグナル 割り込み で中断...

or

$ arecord -D default -r 16000 -c 8 -f S24_3LE tamago_rec.wav
録音中 WAVE 'tamago_rec.wav' : Signed 24 bit Little Endian in 3bytes, レート 16000 Hz, チャネル数 8
^Cシグナル 割り込み で中断...


WSL2 上でCUDAを動作させる方法

下記 nvidia 公式の CUDA インストール手順に従うのがベスト。トラブルを最小にするために、インターネットから隔離されている環境を除いてネットワークインストールを推奨します。
It is best to follow the official nvidia CUDA installation instructions below. To minimize trouble, we recommend network installation, except in environments isolated from the Internet.
CUDA installation instruction for WSL2

2024/03/01 時点の例
Example as of 2024/03/01

$ wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.1-1_all.deb
$ sudo dpkg -i cuda-keyring_1.1-1_all.deb
$ sudo apt update
$ sudo apt install cuda-toolkit-12-3

toolkit のみをインストールするため、 nvidia 社製 GPU が搭載されていない環境でもインストールは可能ですが(恐らくビルドも可能ですが)実行はできません。
Since only the toolkit is installed, it is possible to install (and probably build) even in environments that do not have an nvidia GPU, but it cannot be executed.



HARK 等のビルド時の注意

  • 実行されているディストリビューション内から Windows ホストのネイティブストレージ領域に対して /mnt/c/ などでアクセスが可能ですが、この領域に直接ソースコードを配置してビルドするとエラーが発生することがあります。ソースコードは必ず仮想ストレージ内の Path に配置してください。 Windows ホストのファイルシステムの制約を受けるため、アクセス権の問題やファイル名の大文字小文字の区別が行われないことに起因する予期しない不具合が発生します。例えば Linux 上では Time.htime.h は区別されますが、 Windows 上のストレージに配置したファイルにアクセスすると Case による違いを識別できずエラーとなります。
    Although it is possible to access the native storage area of a Windows host from within the running distribution, such as /mnt/c/ , errors may occur if you place source code directly in this area and build. Be sure to place the source code in Path in virtual storage. Due to the limitations of the Windows host’s file system, unexpected failures may occur due to access rights issues and case insensitivity of file names. For example, on Linux, Time.h and time.h are distinguished, but when accessing a file placed in storage on Windows, the difference depending on the case cannot be distinguished and an error will occur.

Back to Top