Linux Source Code Deployment
It is recommended to use
miniconda
for installation and deployment on Linux to avoid many environment issues.- First, install
miniconda
. Open the terminal and execute the commandwget https://repo.anaconda.com/miniconda/Miniconda3-py310_24.5.0-0-Linux-x86_64.sh
- After the download is complete, execute
bash Miniconda3-py310_24.5.0-0-Linux-x86_64.sh
- Next, some agreements or guides will be displayed; you need to enter
yes
or press Enter to continue. - Once the installation is complete, it's recommended to add it to the global environment so you can use the short command
conda
. By default, it might be installed in/root/miniconda3
. If so, executecp /root/miniconda3/bin/conda /usr/bin/conda
. If it's in a different location, please adjust the path accordingly. - Close and reopen the terminal window for the changes to take effect.
- First, install
Create a virtual environment with
python3.10
by executing the commandconda create -n videotrans python=3.10
. If prompted, enteryes
and press Enter.Activate the virtual environment by executing the command
conda activate videotrans
Create an empty folder for deploying the source code. Assuming
/data/pyvideo
has been created, navigate into the folder and clone the source code from GitHub. Execute the commandgit clone https://github.com/jianchang512/pyvideotrans .
Install the dependencies by executing the command
pip install -r requirements.txt
, and wait for it to complete.Install ffmpeg. On CentOS, execute
yum install ffmpeg
. On Ubuntu, executeapt-get install ffmpeg
If there were no errors, execute
python sp.py
to launch the application orpython api.py
to run the API service.
Possible Errors During Installation
samplerate
module installation failed
You may encounter an error containing the word samplerate
. This is a pip module that requires compilation from source code. Compilation can easily fail on different system versions and environments, leading to errors. The error message will be similar to the following:
-- Build files have been written to: /tmp/pip-install-0355nvxe/samplerate_f6c17d8f7ab94e0b9f8d7e16697c1ab3/build/temp.linux-x86_64-cpython-310/samplerate
[ 14%] Building C object _deps/libsamplerate-build/src/CMakeFiles/samplerate.dir/samplerate.c.o
[ 28%] Building C object _deps/libsamplerate-build/src/CMakeFiles/samplerate.dir/src_linear.c.o
[ 42%] Building C object _deps/libsamplerate-build/src/CMakeFiles/samplerate.dir/src_sinc.c.o
[ 57%] Building C object _deps/libsamplerate-build/src/CMakeFiles/samplerate.dir/src_zoh.c.o
[ 71%] Linking C static library libsamplerate.a
[ 71%] Built target samplerate
[ 85%] Building CXX object CMakeFiles/python-samplerate.dir/src/samplerate.cpp.o
c++: error: unrecognized command line option ‘-std=c++14’
gmake[2]: *** [CMakeFiles/python-samplerate.dir/src/samplerate.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/python-samplerate.dir/all] Error 2
gmake: *** [all] Error 2
The error might also look like this:
centos7 ImportError: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /data2/conda/envs/pyvideo/lib/python3.10/site-packages/shiboken6/Shiboken.abi3.so)
This indicates that the c++/cmake
version is too low and needs to be upgraded. Execute the following commands. If you are on a CentOS
-based system, execute the following commands one by one:
yum update
yum clean all
yum remove devtoolset-8
yum update libstdc++
yum install devtoolset-8 devtoolset-9-libstdc++-devel scl-utils
After running the commands above, execute the following:
export CFLAGS="-fPIC"
export CXXFLAGS="-fPIC"
Then, re-run pip install -r requirements.txt
.
- Using CUDA Acceleration (Execute Separately)
pip uninstall -y torch torchaudio
pip install torch==2.2.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu118
pip install nvidia-cublas-cu11 nvidia-cudnn-cu11