Last active
May 18, 2023 14:32
-
-
Save godie007/96a1f7cb43e9c11e73f59e87771e6ba4 to your computer and use it in GitHub Desktop.
Script para adecuar el ambiente de una nvidia jeton nano 2gb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Actualizar e instalar dependencias | |
sudo apt-get update -y | |
sudo apt-get upgrade -y | |
# Instalar herramientas de compilación | |
sudo apt-get install build-essential cmake git pkg-config -y | |
# Instalar bibliotecas de imágenes y vídeos I/O | |
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng-dev -y | |
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y | |
sudo apt-get install libxvidcore-dev libx264-dev -y | |
# Instalar GTK para OpenCV GUI | |
sudo apt-get install libgtk-3-dev -y | |
# Otras dependencias | |
sudo apt-get install libatlas-base-dev gfortran -y | |
sudo apt-get install python3-dev -y | |
# Instalar pip | |
sudo apt install python3-pip -y | |
# Instalar numpy usando pip | |
pip3 install numpy | |
# Crear ambiente virtual de Python e instalar ipykernel | |
python3 -m venv opencv_cuda | |
source opencv_cuda/bin/activate | |
pip install ipykernel | |
# Descargar OpenCV desde GitHub | |
cd ~ | |
git clone https://github.com/opencv/opencv.git | |
git clone https://github.com/opencv/opencv_contrib.git | |
# Crear directorio de compilación | |
cd ~/opencv | |
mkdir build | |
cd build | |
# Compilar OpenCV con soporte para CUDA | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D INSTALL_PYTHON_EXAMPLES=ON \ | |
-D INSTALL_C_EXAMPLES=OFF \ | |
-D OPENCV_ENABLE_NONFREE=ON \ | |
-D WITH_CUDA=ON \ | |
-D WITH_CUDNN=ON \ | |
-D OPENCV_DNN_CUDA=ON \ | |
-D ENABLE_FAST_MATH=1 \ | |
-D CUDA_FAST_MATH=1 \ | |
-D CUDA_ARCH_BIN=7.5 \ | |
-D WITH_CUBLAS=1 \ | |
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \ | |
-D HAVE_opencv_python3=ON \ | |
-D PYTHON_EXECUTABLE=~/.virtualenvs/opencv_cuda/bin/python \ | |
-D BUILD_EXAMPLES=ON .. | |
# Compilar e instalar OpenCV | |
make -j$(nproc) | |
sudo make install | |
sudo ldconfig | |
# Instalar Jupyter Notebook | |
pip install notebook | |
# Crear un archivo de configuración de Jupyter Notebook | |
jupyter notebook --generate-config | |
# Solicitar contraseña al usuario | |
echo "Introduce la contraseña para Jupyter Notebook:" | |
read -s password | |
password_hash=$(python -c "from notebook.auth import passwd; print(passwd('$password'))") | |
# Escribir contraseña y configuración de puerto en el archivo de configuración | |
echo "c.NotebookApp.password = u'$password_hash'" >> ~/.jupyter/jupyter_notebook_config.py | |
echo "c.NotebookApp.port = 8888" >> ~/.jupyter/jupyter_notebook_config.py | |
echo "c.NotebookApp.ip = '0.0.0.0'" >> ~/.jupyter/jupyter_notebook_config.py | |
# Configuración de Jupyter para inicio automático | |
echo "[Unit] | |
Description=Jupyter Notebook | |
[Service] | |
Type=simple | |
PIDFile=/run/jupyter.pid | |
ExecStart=/home/godie007/.local/bin/jupyter notebook --config=/home/godie007/.jupyter/jupyter_notebook_config.py | |
User=godie007 | |
Group=godie007 | |
WorkingDirectory=/home/godie007/ | |
Restart=always | |
RestartSec=10 | |
[Install] | |
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/jupyter.service | |
# Habilitar Jupyter en el inicio del sistema | |
sudo systemctl enable jupyter | |
# Iniciar el servicio Jupyter | |
sudo systemctl start jupyter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment