Skip to content

Instantly share code, notes, and snippets.

View maslychm's full-sized avatar
🦊

Mykola Maslych maslychm

🦊
View GitHub Profile
@Tushar-N
Tushar-N / pad_packed_demo.py
Last active December 27, 2022 06:35
How to use pad_packed_sequence in pytorch<1.1.0
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
seqs = ['gigantic_string','tiny_str','medium_str']
# make <pad> idx 0
vocab = ['<pad>'] + sorted(set(''.join(seqs)))
# make model
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maslychm
maslychm / pytorch_m1_gpu.MD
Created May 18, 2022 20:58
Install Mac M1 PyTorch GPU support

Install PyTorch 1.12.0 with Mac M1 GPU support (MPS device: for Metal Performance Shaders)

TLDR: Dowload package directly from anaconda.org and install over the current torch version

Explanation

Wrong version (1.10.2) gets installed for me when I run conda install pytorch -c pytorch-nightly.
To fix, install the latest pytorch version from the stable channel, then manually download package for your python version, and install it over the current pytorch. Newest Pytorch Nightly releases here: Anaconda: Pytorch Nightly Files.