The module pycuda.autoinit, when imported, automatically performs all the steps necessary to get CUDA ready for submission of compute kernels. It uses pycuda.tools.make_default_context() to create a compute context.
An instance of pycuda.driver.Device that was used for automatic initialization.
A default-constructed instance of pycuda.driver.Context on device. This context is created by calling pycuda.tools.make_default_context().
Return a pycuda.driver.Context instance chosen according to the following rules:
- If the environment variable CUDA_DEVICE is set, its integer value is used as the device number.
- If the file .cuda-device is present in the user’s home directory, the integer value of its contents is used as the device number.
- Otherwise, all available CUDA devices are tried in a round-robin fashion.
An error is raised if this does not lead to a usable context.
Deprecated. Use make_default_context().
Return a pycuda.driver.Device instance chosen according to the following rules:
- If the environment variable CUDA_DEVICE is set, its integer value is used as the device number.
- If the file .cuda-device is present in the user’s home directory, the integer value of its contents is used as the device number.
- Otherwise, default is used as the device number.
This decorator caches the result of the decorated function, if a subsequent occurs in the same pycuda.driver.Context. This is useful for caching of kernels.
Empties all context-dependent memoization caches. Also releases all held reference contexts. If it is important to you that the program detaches from its context, you might need to call this function to free all remaining references to your context.
This function, meant for use with py.test, will mark func with a “cuda” tag and make sure it has a CUDA context available when invoked.
Gives access to more information on a device than is available through pycuda.driver.Device.get_attribute(). If dev is None, it defaults to the device returned by pycuda.driver.Context.get_device().
The number of threads that participate in banked, simultaneous access to shared memory.
The distance between global memory base addresses that allow accesses of word-size word_size bytes to get coalesced.
Round up bytes to the next alignment boundary as given by align_bytes().
Return self.align_bytes(word_size)/word_size, while checking that the division did not yield a remainder.
Round up elements to the next alignment boundary as given by align_bytes(), where each element is assumed to be dtype_size bytes large.
Round up size to a valid texture channel count.
Calculate occupancy for a given kernel workload characterized by
How many thread blocks execute on each multiprocessor.
How many warps execute on each multiprocessor.
A float value between 0 and 1 indicating how much of each multiprocessor’s scheduling capability is occupied by the kernel.
The functions pycuda.driver.mem_alloc() and pycuda.driver.pagelocked_empty() can consume a fairly large amount of processing time if they are invoked very frequently. For example, code based on pycuda.gpuarray.GPUArray can easily run into this issue because a fresh memory area is allocated for each intermediate result. Memory pools are a remedy for this problem based on the observation that often many of the block allocations are of the same sizes as previously used ones.
Then, instead of fully returning the memory to the system and incurring the associated reallocation overhead, the pool holds on to the memory and uses it to satisfy future allocations of similarly-sized blocks. The pool reacts appropriately to out-of-memory conditions as long as all memory allocations are made through it. Allocations performed from outside of the pool may run into spurious out-of-memory conditions due to the pool owning much or all of the available memory.
An object representing a DeviceMemoryPool-based allocation of linear device memory. Once this object is deleted, its associated device memory is freed. PooledDeviceAllocation instances can be cast to int (and long), yielding the starting address of the device memory allocated.
Explicitly return the memory held by self to the associated memory pool.
Return the size of the allocated memory in bytes.
A memory pool for linear device memory as allocated using pycuda.driver.mem_alloc(). (see Memory Pools)
The number of unused blocks being held by this pool.
The number of blocks in active use that have been allocated through this pool.
Return a PooledDeviceAllocation of size bytes.
Free all unused memory that the pool is currently holding.
Instruct the memory to start immediately freeing memory returned to it, instead of holding it for future allocations. Implicitly calls free_held(). This is useful as a cleanup action when a memory pool falls out of use.
An object representing a PageLockedMemoryPool-based allocation of linear device memory. Once this object is deleted, its associated device memory is freed.
Explicitly return the memory held by self to the associated memory pool.
Return the size of the allocated memory in bytes.
Specifies the set of pycuda.driver.host_alloc_flags used in its associated PageLockedMemoryPool.
A memory pool for pagelocked host memory as allocated using pycuda.driver.pagelocked_empty(). (see Memory Pools)
The number of unused blocks being held by this pool.
The number of blocks in active use that have been allocated through this pool.
Return an uninitialized (“empty”) numpy.ndarray with the given shape, dtype, and order. This array will be backed by a PooledHostAllocation, which can be found as the .base attribute of the array.
Free all unused memory that the pool is currently holding.
Instruct the memory to start immediately freeing memory returned to it, instead of holding it for future allocations. Implicitly calls free_held(). This is useful as a cleanup action when a memory pool falls out of use.