This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nvidia-smi --query-gpu=power.draw,clocks.current.graphics,clocks.current.memory,utilization.gpu,utilization.memory --format=csv --loop-ms=1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import numpy as np | |
from matplotlib import pyplot as plt | |
# replace with np.fft or scipy.fft if you don't have it installed, | |
# not central to the demonstration, but better multi-threading | |
# "the point" is to examine parallelization over N "whole tasks" | |
# using ray or another lib, vs using low-level parallelization | |
# by threading each array op |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from concurrent.futures import ThreadPoolExecutor, wait | |
def slices_for_split(N, m): | |
"""Split an array of length N into m chunks, with the final chunk being a bit smaller if need be. | |
Does not actually split, returns a list of slice objects for reuse. | |
""" | |
# this code is largely adapted from the numpy source code | |
Neach_section, extras = divmod(N, m) | |
Neach_section, extras |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from io import BytesIO | |
import requests | |
from imageio import imread | |
if __name__ == '__main__': | |
url = 'http://localhost:5000/wrong-gpu-and-memory-leak' | |
while True: | |
resp = requests.get(url) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
calcac/b(n, α, β, x) | |
Two functions calcac and calcb compute the three coefficients in the recurrence | |
relation for the Jacobi polynomial. It is broken into two functions to separate | |
a and c, which do not depend on x and can be calculated once for a vector of x, | |
from b which does depend on x and must be calculated for each element. | |
n is the order of the polynomial. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function abc(n, α, β, x) | |
# the parens emphasize the terms, not PEMDAS | |
a = (2n) * (n + α + β) * (2n + α + β - 2) | |
b1 = (2n + α + β -1) | |
b2 = (2n + α + β) | |
b2 = b2 * (b2 - 2) | |
b = b1 * (b2 * x + α^2 - β^2) | |
c = 2 * (n + α - 1) * (n + β - 1) * (2n + α + β) | |
return a, b, c | |
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from prysm import AiryDisk, SiemensStar | |
from matplotlib import pyplot as plt | |
oversamp=8 | |
obj = SiemensStar(32, sinusoidal=False, sample_spacing=5/oversamp, samples=512*oversamp).msaa(oversamp) | |
psf = AiryDisk(fno=32, wavelength=.55, extent=obj.support/2, samples=obj.samples_x) | |
obj.plot2d(xlim=50, interpolation='bilinear') | |
blurred = obj.conv(psf) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder