Skip to content

Instantly share code, notes, and snippets.

View hwvs's full-sized avatar
:shipit:
Ship it

Hunter W. Watson hwvs

:shipit:
Ship it
View GitHub Profile
@hwvs
hwvs / Get-FreeTcpPort.ps1
Created January 26, 2024 20:53
Get-FreeTcpPort retrieves a random available/inactive TCP port within a specified range
<#
.SYNOPSIS
Get-FreeTcpPort retrieves an available TCP port within a specified range.
.DESCRIPTION
The Get-FreeTcpPort function searches for an available TCP port within the specified range. It checks both active and inactive TCP ports and returns a free port.
.PARAMETER Start
The starting port number of the range
@hwvs
hwvs / fix_cudaHostRegister.py
Last active January 17, 2025 02:55
[PyTorch] Fix cudaHostRegister->pinned_use_cuda_host_register:False on Windows with Nvidia GTX 1070/1080
import torch
import re
# ....
# Fix for cudaHostRegister on Windows with Nvidia GTX 1070/1080 ( Hunter Watson | github.com/hwvs )
# Resolves: "RuntimeError: Host and device pointer dont match with cudaHostRegister. Please dont use this feature by setting PYTORCH_CUDA_ALLOC_CONF=use_cuda_host_register:False (default)"
# Tested on:
# -- Unsloth 2025.1.1: Fast Qwen2 patching. Transformers: 4.46.3.
# -- GPU: NVIDIA GeForce GTX 1070. Max memory: 8.0 GB. Platform: Windows.