Skip to content

Instantly share code, notes, and snippets.

View zachnicoll's full-sized avatar
💻
Working @ Airteam

Zach Nicoll zachnicoll

💻
Working @ Airteam
View GitHub Profile
@zachnicoll
zachnicoll / stream_bytes_io_quickly.py
Created April 3, 2023 01:39
FastAPI's (Starlette's) `StreamingReponse` is slow when streaming file-like objects. This gist demonstrates how to quickly stream bytes as 1MB chunks back to the client.
CHUNK_SIZE = 1024 * 1024 # 1MB chunk size
def read_bytes_as_chunks(bytesIO: io.BytesIO) -> Generator[bytes, None, None]:
# Make sure we're at the start of the buffer
bytesIO.seek(0)
with bytesIO as b:
while chunk := b.read(CHUNK_SIZE):
yield chunk
@zachnicoll
zachnicoll / types.d.ts
Last active October 4, 2022 03:36
Typescript Override process.env Typing
declare namespace NodeJS {
export interface ProcessEnv {
VAR_1: string;
VAR_2: string;
}
}
@zachnicoll
zachnicoll / CMAKE_CUDA_ARCHITECTURES_GPU_list.md
Last active October 4, 2022 03:31
CMAKE_CUDA_ARCHITECTURES GPU List. Versions are written without the decimal point in CMakeLists.txt. E.g. version 5.0 will be 50.

How To

Find your GPU and add its respective Compute Capability to your project's CMakeLists.txt file, under the CMAKE_CUDA_ARCHITECTURES variable, like so:

SET(CMAKE_CUDA_ARCHITECTURES 61)

Remember to remove the decimal point in the Compute Capability version number!

GPU List