Linux Source Code Deployment
It is recommended to use
miniconda
on Linux for source code deployment to avoid many environment problems.- First, install
miniconda
. Open the terminal and execute the command:wget https://repo.anaconda.com/miniconda/Miniconda3-py310_24.5.0-0-Linux-x86_64.sh
- After the download is complete, continue to 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. - After the prompt is completed, 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 another location, please replace it yourself. - Close the terminal window and reopen it for the environment to take effect.
- First, install
Create a virtual environment using
python3.10
. Execute the commandconda create -n videotrans python=3.10
. If prompted, enteryes
and then press Enter.Activate the virtual environment. Execute the command
conda activate videotrans
Create an empty folder for deploying the source code. Assuming you have created
/data/pyvideo
, 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
and wait for the prompt to complete.Install ffmpeg. Execute
yum install ffmpeg
under CentOS, andapt-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 FailedYou may encounter an error including the word
samplerate
. This is a pip module that needs to be installed by compiling the source code. It is very easy to fail during compilation and cause 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 indicates that the `c++/cmake` version is too low and needs to be upgraded. Next, execute the following commands. If it is a `centos` series, execute the following respectively:
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 pip installation is very slow, consider switching to the Aliyun 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 Aliyun mirror source may be missing some module versions. 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 content inside, and the official source will be restored.
- Use CUDA Acceleration, Execute Separately
Example
pip3 uninstall -y torch torchaudio
pip3 install torch torchaudio --index-url https://download.pytorch.org/whl/cu126
pip3 install nvidia-cublas-cu12 nvidia-cudnn-cu12