Skip to content

Instantly share code, notes, and snippets.

Follow the instructions
https://github.com/Syllo/nvtop?tab=readme-ov-file#nvtop-build
cmake .. -DNVIDIA_SUPPORT=ON -DAMDGPU_SUPPORT=OFF -DINTEL_SUPPORT=OFF -DMSM_SUPPORT=OFF -DPANFROST_SUPPORT=OFF -DPANTHOR_SUPPORT=OFF
@discort
discort / how-to-install-openssl-1.1.1-on-centos-7.md
Last active February 18, 2024 17:12 — forked from Bill-tran/how-to-install-openssl-1.1.1-on-centos-7.md
How to install openssl 1.1.1 on CentOS 7

Install Python3.10 on Red Hat

# Install OpenSSL 1.1.1
cd /opt
curl https://ftp.openssl.org/source/old/1.1.1/openssl-1.1.1j.tar.gz --output openssl.tar.gz
tar xzf openssl.tar.gz
rm openssl.tar.gz
cd openssl-1.1.1j/
./config --prefix=/opt/openssl && make && make install
@discort
discort / holdout.py
Created November 30, 2023 11:40
Holdout cross-validation generator
# https://fa.bianp.net/blog/2015/holdout-cross-validation-generator/
import numpy as np
from sklearn.utils import check_random_state
class HoldOut:
"""
Hold-out cross-validator generator. In the hold-out, the
data is split only once into a train set and a test set.
Unlike in other cross-validation schemes, the hold-out
@discort
discort / jit_gru.py
Created August 24, 2022 10:44
Torchscript version of nn.GRU with dropout
from collections import OrderedDict
import math
from typing import List, Tuple
import torch
import torch.jit as jit
import torch.nn as nn
from torch.nn import Parameter
from torch import Tensor
@discort
discort / download_glue_data.py
Created November 6, 2021 11:54 — forked from vlasenkoalexey/download_glue_data.py
Fixed W4ngatang/download_glue_data.py script to download GLUE data
''' Script for downloading all GLUE data.
Note: for legal reasons, we are unable to host MRPC.
You can either use the version hosted by the SentEval team, which is already tokenized,
or you can download the original data from (https://download.microsoft.com/download/D/4/6/D46FF87A-F6B9-4252-AA8B-3604ED519838/MSRParaphraseCorpus.msi) and extract the data from it manually.
For Windows users, you can run the .msi file. For Mac and Linux users, consider an external library such as 'cabextract' (see below for an example).
You should then rename and place specific files in a folder (see below for an example).
mkdir MRPC
cabextract MSRParaphraseCorpus.msi -d MRPC
@discort
discort / ohem.py
Created September 12, 2021 17:22
Online hard example mining
import torch
from torch import Tensor
import torch.nn as nn
class OHEM(nn.Module):
"""
Online hard example mining.
Details: <https://arxiv.org/pdf/1604.03540.pdf>
"""
@discort
discort / hooks.py
Created July 31, 2021 21:16
PyTorch hooks
# based on https://medium.com/the-dl/how-to-use-pytorch-hooks-5041d777f904
class VerboseExecution(nn.Module):
def __init__(self, model: nn.Module):
super().__init__()
self.model = model
# Register a hook for each layer
for name, layer in self.model.named_children():
@discort
discort / timing.py
Created July 20, 2021 09:59
Timing decorator
# https://stackoverflow.com/a/27737385/3960038
from functools import wraps
from time import time
def timing(f):
@wraps(f)
def wrap(*args, **kw):
ts = time()
result = f(*args, **kw)
@discort
discort / async_fetch.py
Created July 5, 2021 14:08
Fetching via queue
import asyncio
import aiohttp
async def fetch(session, url):
async with session.get(url) as response:
return await response.text()
async def consumer(queue, session):
@discort
discort / remote_subl.md
Last active June 17, 2021 10:03
Editing remote files on sublime

Editing remote files on sublime

sudo curl -o /usr/local/bin/rmate https://raw.githubusercontent.com/aurora/rmate/master/rmate
sudo chmod +x /usr/local/bin/rmate
sudo mv /usr/local/bin/rmate /usr/local/bin/subl

source