Skip to content

Instantly share code, notes, and snippets.

@MihailCosmin
MihailCosmin / cuda_11.8_installation_on_Ubuntu_22.04
Last active May 18, 2024 22:39 — forked from primus852/cuda_11.7_installation_on_Ubuntu_22.04
Instructions for CUDA v11.8 and cuDNN 8.7 installation on Ubuntu 22.04 for PyTorch 2.0.0
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
@jambonn
jambonn / protobuf-ubuntu-20-04.md
Last active October 26, 2023 07:50
How to Install Protobuf on Ubuntu 20.04
1. sudo apt-get install autoconf automake libtool curl make g++ unzip -y
2. Download the appropriate release here:
https://github.com/protocolbuffers/protobuf/releases/tag/v3.5.1 <protobuf-all-3.5.1.tar.gz
>
3. Unzip the folder
4. Enter the folder and run ./autogen.sh && ./configure && make
5. Then run these other commands. They should run without issues:
$ make check
$ sudo make install
@Huud
Huud / Calculate_Mean_and_std_of_dataset.py
Created July 23, 2020 14:18
How to calculate the mean and standard deviation of an image dataset
# calculate mean and std deviation
from pathlib import Path
import cv2
imageFilesDir = Path(r'C:\your\dataset\dir\here\trainData')
files = list(imageFilesDir.rglob('*.png'))
# Since the std can't be calculated by simply finding it for each image and averaging like
# the mean can be, to get the std we first calculate the overall mean in a first run then
@nguyendv
nguyendv / multi-handlers-logger.py
Last active January 4, 2024 16:38
Python logger with multiple handlers (stream, file, etc.), so you can write log to multiple targets at once
import logging
from logging.handlers import RotatingFileHandler
def setup_logger():
MAX_BYTES = 10000000 # Maximum size for a log file
BACKUP_COUNT = 9 # Maximum number of old log files
# The name should be unique, so you can get in in other places
# by calling `logger = logging.getLogger('com.dvnguyen.logger.example')
logger = logging.getLogger('com.dvnguyen.logger.example')
##### server.py start #####
from concurrent import futures
import time
import logging
import grpc
import chunker_pb2
import chunker_pb2_grpc