Linux Source Code Deployment
It is recommended to use
minicondafor installation and deployment on Linux to avoid many environment issues.- First, install
miniconda. Open the terminal and run the command:wget https://repo.anaconda.com/miniconda/Miniconda3-py310_24.5.0-0-Linux-x86_64.sh - After the download completes, continue with:
bash Miniconda3-py310_24.5.0-0-Linux-x86_64.sh - Some agreements or prompts will appear; enter
yesor press Enter to proceed. - Once the installation is complete, it is recommended to add it to the global environment for easy use of the
condacommand. By default, it may be installed in/root/miniconda3. If so, run:cp /root/miniconda3/bin/conda /usr/bin/conda. Replace the path if it is different. - Close the terminal window and reopen it for the environment to take effect.
- First, install
Create a virtual environment using
python3.10by running:conda create -n videotrans python=3.10. If prompted, enteryesand press Enter.Activate the virtual environment with:
conda activate videotransCreate an empty folder for deploying the source code. Assuming you have created
/data/pyvideo, navigate into it and pull the source code from GitHub with:git clone https://github.com/jianchang512/pyvideotrans .Install dependencies by running:
pip install -r requirements.txt. Wait for the process to complete.Install ffmpeg: on CentOS, run
yum install ffmpeg; on Ubuntu, runapt-get install ffmpeg.If there are no errors, run
python sp.pyto open the software, orpython api.pyto start the API service.
Possible Errors During Installation
Failed to Install the
samplerateModule You might encounter an error related tosamplerate, a pip module that requires compiling source code. This can easily fail due to different system versions and environments. The error code may look like this:-- 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 2Or the error might be:
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++/cmakeversion is too low and needs an upgrade. For CentOS systems, run the following commands:yum update yum clean all yum remove devtoolset-8 yum update libstdc++ yum install devtoolset-8 devtoolset-9-libstdc++-devel scl-utilsAfter that, run:
export CFLAGS="-fPIC" export CXXFLAGS="-fPIC"Then re-run
pip install -r requirements.txt.Pip Mirror Source Issues If pip installation is very slow, consider switching to the Alibaba Cloud mirror source to speed it up. Run the following two commands to switch to the Alibaba mirror, then reinstall:
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ pip config set install.trusted-host mirrors.aliyun.comThe Alibaba Cloud mirror might lack some module versions. If you encounter this issue and want to switch back to the official default source, navigate to
cd ~/.config/pip, open thepip.conffile, delete its contents, and the official source will be restored.Using CUDA Acceleration Run the following commands 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
