Ubuntu22.04 で
ラズパイゼロWからのダイレクト TCP ストリーミングでの配信されている画像を
OpenCV
で再生する
VOICEVOX REST-APIを使えるようにする
とりあえずOpenCV から入れる
https://monobook.org/wiki/Ubuntu_22.04_LTSにVoiceVoxをインストールする
でvoiceboxを入れる
sudo apt install fuse libfuse2
を入れておく
https://voicevox.hiroshiba.jp
から
OS Linux
対応モード CPU
インストーラタイプをダウンロード
cd Downloads
scp VOICEVOX-CPU.Installer.0.14.7.Linux.sh snowpool@192.168.1.69:/home/snowpool/
でM1MacbookAir からscp で転送する
bash VOICEVOX-CPU.Installer.0.14.7.Linux.sh
を実行したが
* curl コマンドが見つかりません。
以下のコマンドを実行してください。
Ubuntu/Debian:
sudo apt install curl
CentOS/Fedora:
sudo dnf install curl
もしくは
sudo yum install curl
となるので
sudo apt install curl
の後に実行したら
+-+-+-+-+-+-+-+-+
|V|O|I|C|E|V|O|X|
+-+-+-+-+-+-+-+-+-+-+-+-+-+
|I|n|s|t|a|l|l|e|r|
+-+-+-+-+-+-+-+-+-+-+-+-+-+
|f|o|r| |L|i|n|u|x|
+-+-+-+-+-+-+-+-+-+
[+] Checking installer prerequisites...
[!] Command '7z', '7zr' or '7za' not found
Required to extract compressed files
Ubuntu/Debian:
sudo apt install p7zip
CentOS (Enable EPEL repository):
sudo dnf install epel-release && sudo dnf install p7zip
Or
sudo yum install epel-release && sudo yum install p7zip
Fedora:
sudo dnf install p7zip
Or
sudo yum install p7zip
Arch Linux:
sudo pacman -S p7zip
MacOS:
brew install p7zip
となるので
sudo apt install p7zip
の後に
bash VOICEVOX-CPU.Installer.0.14.7.Linux.sh
でインストール成功
起動は
~/.voicevox/VOICEVOX.AppImage
だと
configMigration014: /home/snowpool/.config/voicevox-cpu/config.json not exists, do nothing
[26521:0923/052732.856278:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
[26521:0923/052732.856458:ERROR:env.cc(226)] The platform failed to initialize. Exiting.
Segmentation fault (コアダンプ)
となってしまう
普通にubuntu へログインし
GUIから起動すれば問題なく動くが
https://qiita.com/uezo/items/7e476147ec6312ad8a2c
で
.runで実行
M1Macでも動作したので
同様にubuntu でもできると思ったがコマンドが見つからない
https://ponkichi.blog/voicevox-python-curl#st-toc-h-7
を参考に
とりあえず
sudo find / -name ".run"
を実行したが
[sudo] snowpool のパスワード:
find: ‘/run/user/1000/doc’: 許可がありません
find: ‘/run/user/1000/gvfs’: 許可がありません
find: ‘/run/user/127/doc’: 許可がありません
find: ‘/run/user/127/gvfs’: 許可がありません
となる
なおFWは関係なかった
https://server-network-note.net/2022/07/ubuntu-server-22-04-lts-firewall-ufw/
を参考にsudo ufw status で確認したが
無効になっていた
とりあえず保留してopencvを先に進める
https://www.kkaneko.jp/tools/ubuntu/ubuntu_opencv.html#S1
を参考に
まず cmakeのインストール
sudo apt -y install build-essential gcc g++ make libtool texinfo dpkg-dev pkg-config
sudo apt -y install qt5-qmake
sudo apt -y install git cmake cmake-curses-gui cmake-gui curl
sudo apt -y install zlib1g-dev libcurl4-gnutls-dev
cd /tmp
git clone https://github.com/Kitware/CMake.git
cd CMake/
./configure --system-curl --system-zlib
Make
Sudo make install
次にpython3 関連
sudo apt -y install python-is-python3 python3-dev python-dev-is-python3 python3-pip python3-setuptools python3-venv build-essential
次に
OpenCV, opencv_contrib のインストール
sudo mkdir -p /usr/local/opencv
sudo chown -R $USER /usr/local/opencv
cd /usr/local/opencv
curl -O https://github.com/opencv/opencv/archive/4.x.zip
cp 4.x.zip opencv.zip
curl -O https://github.com/opencv/opencv_contrib/archive/4.x.zip
cp 4.x.zip opencv_contrib.zip
unzip opencv.zip
Archive: opencv.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of opencv.zip or
opencv.zip.zip, and cannot find opencv.zip.ZIP, period.
となるので
https://www.kkaneko.jp/tools/ubuntu/ubuntu_opencv_buildout.html
と
https://toolatescrap.hatenablog.com/entry/2022/11/29/003848
を参考に
https://opencv.org/releases/
からmacでダウンロードしたが展開される
https://github.com/opencv/opencv/tree/4.7.0
からzipダウンロードしたが同じ
どうやらMacでzipダウンロードすると展開されるらしい
sudo apt install libgtk2.0-dev
で先にインストールしておく
https://www.kkaneko.jp/tools/ubuntu/ubuntu_opencv_buildout.html#S2
を参考に
Ceres Solver のインストール
sudo apt -y install libceres-dev libceres2
次にpython3関連
https://www.kkaneko.jp/tools/man/python.html#systempython
によれば
Ubuntu では,システム Python は,Ubuntu システムの動作に関わっている. システム Python をバージョンアップしたり,アンインストールを行ったりするのは良くない
と言うことなので
Pyenvを使うようにする
sudo apt -y install --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
cd /tmp
curl https://pyenv.run | bash
echo 'export PYENV_ROOT="${HOME}/.pyenv"' >> ~/.bashrc
echo 'if [ -d "${PYENV_ROOT}" ]; then' >> ~/.bashrc
echo ' export PATH=${PYENV_ROOT}/bin:$PATH' >> ~/.bashrc
echo ' eval "$(pyenv init -)"' >> ~/.bashrc
echo ' eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
echo 'fi' >> ~/.bashrc
exec $SHELL -l
他の必要なものもインストールするので
https://www.kkaneko.jp/tools/ubuntu/ubuntu.html#Se
を参考に
sudo apt -y install git cmake cmake-curses-gui cmake-gui curl wget p7zip-full
次にpython関連
python-is-python3 python3-dev python-dev-is-python3 python3-pip python3-setuptools python3-venv build-essential
sudo apt -y install python-is-python3 python3-dev python-dev-is-python3 python3-pip python3-setuptools python3-venv build-essential
sudo pip3 uninstall ptyprocess sniffio terminado tornado jupyterlab jupyter jupyter-console jupytext nteract_on_jupyter spyder
を実行したら
do tornado jupyterlab jupyter jupyter-console jupytext nteract_on_jupyter spyder
Found existing installation: ptyprocess 0.7.0
Not uninstalling ptyprocess at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'ptyprocess'. No files were found to uninstall.
WARNING: Skipping sniffio as it is not installed.
WARNING: Skipping terminado as it is not installed.
WARNING: Skipping tornado as it is not installed.
WARNING: Skipping jupyterlab as it is not installed.
WARNING: Skipping jupyter as it is not installed.
WARNING: Skipping jupyter-console as it is not installed.
WARNING: Skipping jupytext as it is not installed.
WARNING: Skipping nteract_on_jupyter as it is not installed.
WARNING: Skipping spyder as it is not installed.
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
となった
おそらく競合しないため念のためアンインストールしてるっぽい
sudo apt -y install jupyter jupyter-qtconsole spyder3
sudo apt -y install python3-ptyprocess python3-sniffio python3-terminado python3-tornado
sudo pip3 install -U jupyterlab jupyter jupyter-console jupytext nteract_on_jupyter
これで
JupyterLab, spyder, nteract
をインストール
sudo apt -y install python3-numpy python3-sklearn
で
numpy, scikit-learn のインストール
次に
TensorFlow 2.11,Keras,MatplotLib, Python 用 opencv-python のインストール
トラブルの可能性を減らすため
アンインストールをしておく
sudo apt -y remove python3-keras
sudo pip3 uninstall -y tensorflow tensorflow-cpu tensorflow-gpu tensorflow-intel tensorflow-text tensorflow-estimator tf-models-official tf_slim tensorflow_datasets tensorflow-hub keras keras-tuner keras-visualizer
クリーンインストール状態なので
WARNING: Skipping tensorflow as it is not installed.
WARNING: Skipping tensorflow-cpu as it is not installed.
WARNING: Skipping tensorflow-gpu as it is not installed.
WARNING: Skipping tensorflow-intel as it is not installed.
WARNING: Skipping tensorflow-text as it is not installed.
WARNING: Skipping tensorflow-estimator as it is not installed.
WARNING: Skipping tf-models-official as it is not installed.
WARNING: Skipping tf_slim as it is not installed.
WARNING: Skipping tensorflow_datasets as it is not installed.
WARNING: Skipping tensorflow-hub as it is not installed.
WARNING: Skipping keras as it is not installed.
WARNING: Skipping keras-tuner as it is not installed.
WARNING: Skipping keras-visualizer as it is not installed.
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
となった
TensorFlow の前提パッケージのインストール
sudo pip3 uninstall -y six wheel astunparse tensorflow-estimator numpy keras-preprocessing absl-py wrapt gast flatbuffers grpcio opt-einsum protobuf termcolor typing-extensions google-pasta h5py tensorboard-plugin-wit markdown werkzeug requests-oauthlib rsa cachetools google-auth google-auth-oauthlib tensorboard tensorflow
sudo apt -y install python3-six python3-wheel python3-numpy python3-grpcio python3-protobuf python3-termcolor python3-typing-extensions python3-h5py python3-markdown python3-werkzeug python3-requests-oauthlib python3-rsa python3-cachetools python3-google-auth
次に
TensorFlow, numpy, pillow, pydot, matplotlib, keras, opencv-python のインストール
sudo apt -y update
sudo apt -y install python3-numpy python3-pil python3-pydot python3-matplotlib
sudo apt -y install libopencv-dev libopencv-core-dev python3-opencv libopencv-contrib-dev opencv-data
sudo pip3 install -U tensorflow tf-models-official tf_slim tensorflow_datasets tensorflow-hub keras keras-tuner keras-visualizer
sudo pip3 install git+https://github.com/tensorflow/docs
sudo pip3 install git+https://github.com/tensorflow/examples.git
sudo pip3 install git+https://www.github.com/keras-team/keras-contrib.git
インストール完了後
python3 -c "import tensorflow as tf; print( tf.__version__ )"
でバージョン確認
2023-09-26 06:14:43.998359: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-09-26 06:14:44.053113: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-09-26 06:14:45.376154: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2.13.0
となった
とりあえずここまで
次にPyTorch などをインストールする