50 private links
https://namvu.net/2021/07/setup-a-family-printer-with-a-raspberry-pi-1-and-canon-lbp-2900/
sudo apt install git build-essential automake cups libcups2-dev
git clone https://github.com/mounaiban/captdriver.git
cd captdriver
aclocal
autoconf
automake --add-missing
./configure
make
make ppd
sudo make install
sudo cp -p /usr/local/bin/rastertocapt /usr/lib/cups/filter/
sudo cp ppd/*.ppd /usr/share/ppd/custom/
Compile the kernel
# Install the needed packages
sudo apt install -y build-essential bison dwarves flex libssl-dev libelf-dev
# Clone kernel source
git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
cd WSL2-Linux-Kernel
# Config kernel
cp Microsoft/config-wsl .config
sed -i 's/microsoft-standard-WSL2/generic/' .config # Change the LOCALVERSION value
sed -i 's/# CONFIG_SOUND is not set/CONFIG_SOUND=y\nCONFIG_SND=y/' .config # Enable sound modules
make olddefconfig
# Now that everything is ready, let's compile the kernel
make -j $(nproc)
# Copy the kernel into a directory in the Windows filesystem
mkdir /mnt/c/wslkernel
cp arch/x86/boot/bzImage /mnt/c/wslkernel/custom_kernel
# Last step, the kernel needs to be referenced in the file .wslconfig
nano /mnt/c/Users/<your username>/.wslconfig
The content of the .wslconfig
should look like this:
[wsl2]
kernel = c:\\wslkernel\\custom_kernel
Now, reboot WSL by running the following command in PowerShell:
wsl --shutdown
Launch again a terminal with your WSL2 distro and confirm the new kernel is now being the one used:
uname -a
You should see generic
in the output.
Install headers (for developing kernel modules)
sed -i 's/SPDX-License-Identifier: GPL-2.0/SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note/g' include/uapi/misc/d3dkmthk.h
sudo make headers_install INSTALL_HDR_PATH=/usr
sudo mkdir -p /lib/modules/$(uname -r)
sudo ln -s <path to WSL2-Linux-Kernel> /lib/modules/$(uname -r)/build
- Follow this instruction from NVIDIA to install CUDA drivers for WSL.
DO NOT install CUDA Toolkit yet. The version in that instruction is not compatible with current version of Tensorflow/Pytorch.
- Install CUDA Toolkit 11.8.0 for WSL:
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda
Add CUDA to path:
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.zshrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.zshrc
Symlink libcuda (needed for building darknet):
sudo ln -s /usr/lib/wsl/lib/libcuda.so.1 /usr/local/cuda/lib64/libcuda.so
- Install cuDNN
Go to https://developer.nvidia.com/rdp/cudnn-download and download cuDNN for CUDA 11.x for Linux.
Filename: cudnn-linux-x86_64-8.9.4.25_cuda11-archive.tar.xz
tar -xvf cudnn-linux-x86_64-8.9.4.25_cuda11-archive.tar.xz
cd cudnn-linux-x86_64-8.9.4.25_cuda11-archive
sudo cp -P include/* /usr/local/cuda/include/
sudo cp -P lib/* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
sudo ldconfig /usr/local/cuda/lib64
-
Install pyenv and create a virtual environment
-
Install Tensorflow and Pytorch:
pip install --upgrade pip setuptools wheel
pip install torch torchvision torchaudio
pip install tensorflow
- Install additional packages (optional):
pip install jupyterlab
In a nutshell: to avoid your shell character set from messing with imports, use -r to export and SOURCE when importing.
Dumping safely
# Do not do this, since it might screw up encoding
mysqldump -uroot -p database > utf8.dump # this is bad
Better do:
mysqldump -uroot -p database -r utf8.dump
Note that when your MySQL server is not set to UTF-8 you need to do mysqldump --default-character-set=latin1
(!) to get a correctly encoded dump. In that case, you will also need to remove the SET NAMES='latin1'
comment at the top of the dump, so the target machine won't change its UTF-8 charset when sourcing.
If you only want to dump the structure without data, use
mysqldump -uroot -p --no-data database -r utf8.dump
Importing a dump safely
# Do not do this, since it might screw up encoding
mysql -u username -p database < dump_file # this is bad
Better do:
mysql -uroot -p --default-character-set=utf8mb4 database
mysql> SET names 'utf8';
mysql> SOURCE utf8.dump;
Ref: https://makandracards.com/makandra/595-dumping-and-importing-from-to-mysql-in-an-utf-8-safe-way
- Hold down the Windows key and press R to bring up the Run dialog.
- Type
gpedit.msc
and press Enter. You will need administrator privileges to continue. - Navigate to User Configuration > Administrative Templates > Windows Components > Attachment Manager.
- In the right-side pane, double-click "Do not preserve zone information in file attachments", set it to Enabled, then press OK.
Installing the prerequisites
sudo apt update
sudo apt upgrade
sudo apt install build-essential python3-dev python3-pip libseccomp-dev libxml2-dev libxslt1-dev zlib1g-dev gettext curl redis-server mariadb-server libmysqlclient-dev
nvm install 18
nvm alias default 18
Creating the database
sudo service mariadb start
sudo mysql_secure_installation
sudo mysql
CREATE USER 'dmoj'@'localhost' IDENTIFIED BY 'PASSWORD';
CREATE USER 'dmoj'@'%' IDENTIFIED BY 'PASSWORD';
CREATE DATABASE dmoj DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON dmoj.* TO 'dmoj'@'localhost';
GRANT ALL PRIVILEGES ON dmoj.* TO 'dmoj'@'%';
exit
Cloning VNOJ
git clone --recursive https://github.com/VNOI-Admin/OJ.git
cd OJ
Installing prerequisites
We will create a virtual environment with pyenv
and install the dependencies:
pyenv install 3.11.9
pyenv virtualenv 3.11.9 vnoj
pyenv local vnoj
pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
pip install -r additional_requirements.txt
pip install flake8 flake8-import-order flake8-future-import flake8-commas flake8-logging-format flake8-quotes
npm install
Configuring
Start up the Redis server, which is needed by the Celery workers:
sudo service redis-server start
Download the sample settings file:
cd dmoj
wget https://github.com/DMOJ/docs/raw/master/sample_files/local_settings.py
You will now need to configure dmoj/local_settings.py
. You need to update MySQL credentials and the secret key and uncommenting CELERY_BROKER_URL
and CELERY_RESULT_BACKEND
. By default, Redis listens on localhost
port 6379
, which is reflected in local_settings.py
. You will need to update the addresses if you changed Redis's settings.
Now, verify that everything is going according to plan:
./manage.py check
Compiling assets
Compile and optimize the stylesheets:
./make_style.sh
Collect static files into STATIC_ROOT
as specified in dmoj/local_settings.py
:
./manage.py collectstatic --no-input
Generate internationalization files:
./manage.py compilemessages
./manage.py compilejsi18n
Setting up database tables
If you have a database backup, skip this step.
Generate the schema for the database and load some initial data:
./manage.py migrate
./manage.py loaddata navbar
./manage.py loaddata language_small
./manage.py loaddata demo
Create an admin account:
./manage.py createsuperuser
Running the server
You need to start MySQL and Redis after restart:
sudo service mariadb start
sudo service redis-server start
Let's run the server, and see if it all works:
./manage.py runserver 0.0.0.0:8000