Linux Source Code Deployment
- It is recommended to use
miniconda
to install and deploy on Linux, which can avoid many environment problems.
- 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
- Wait for the download to complete, and then execute
bash Miniconda3-py310_24.5.0-0-Linux-x86_64.sh
- Next, some agreements or guides will be displayed, and you need to enter
yes
or press Enter to continue. - After waiting for the prompt to complete, it is recommended to add it to the global environment so that you can use the short command
conda
. The default may be installed under/root/miniconda3
. If it is this command, please executecp /root/miniconda3/bin/conda /usr/bin/conda
, if it is in other locations, please replace it yourself - Close the terminal window and reopen it for the environment to take effect.
- Create a virtual environment using
python3.10
, execute the commandconda create -n videotrans python=3.10
, if prompted to enter, enteryes
and press Enter. - Activate the virtual environment, execute the command
conda activate videotrans
- Create an empty folder for deploying the source code. Assuming that
/data/pyvideo
has been created, enter the folder and pull the source code from github, execute the commandgit clone https://github.com/jianchang512/pyvideotrans .
- Install dependencies, execute the command
pip install -r requirements.txt
, wait for the prompt to complete - Install ffmpeg, execute
yum install ffmpeg
under centos, and executeapt-get install ffmpeg
under ubuntu - If there are no errors, execute
python sp.py
to open the software, and executepython api.py
to run the api service
Possible Errors During Installation
- Samplerate module installation failed You may encounter an error that includes the word
samplerate
. This is a pip module that needs to be compiled from source code. It is extremely easy to fail to compile and report an error in different system versions and environments. The error code is 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 may also be as follows
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 situation indicates that the c++/cmake
version is too low and needs to be upgraded. Execute the following commands. For the centos
series, execute the following separately
yum update
yum clean all
yum remove devtoolset-8
yum update libstdc++
yum install devtoolset-8 devtoolset-9-libstdc++-devel scl-utils
After the execution is complete, continue to execute
export CFLAGS="-fPIC"
export CXXFLAGS="-fPIC"
Then re-execute pip install -r requirements.txt
- Pip mirror source problem
If the pip installation is very slow, you can consider switching to the Alibaba Cloud mirror source to speed up the installation. Execute the following 2 commands to switch the pip mirror to the Alibaba mirror, and then reinstall
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set install.trusted-host mirrors.aliyun.com
The Alibaba Cloud mirror source may lack versions of some modules. If you encounter this problem and want to switch back to the official default source, execute cd ~/.config/pip
, open the pip.conf file, delete the contents inside, and you can restore the official source
- To use 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