[docs]defis_built():r"""Returns whether PyTorch is built with CUDA support. Note that this doesn't necessarily mean CUDA is available; just that if this PyTorch binary were run a machine with working CUDA drivers and devices, we would be able to use it."""returntorch._C.has_cuda
classcuFFTPlanCacheAttrContextProp(object):# Like regular ContextProp, but uses the `.device_index` attribute from the# calling object as the first argument to the getter and setter.def__init__(self,getter,setter):self.getter=getterself.setter=setterdef__get__(self,obj,objtype):returnself.getter(obj.device_index)def__set__(self,obj,val):ifisinstance(self.setter,str):raiseRuntimeError(self.setter)self.setter(obj.device_index,val)classcuFFTPlanCache(object):r""" Represents a specific plan cache for a specific `device_index`. The attributes `size` and `max_size`, and method `clear`, can fetch and/ or change properties of the C++ cuFFT plan cache. """def__init__(self,device_index):self.device_index=device_indexsize=cuFFTPlanCacheAttrContextProp(torch._cufft_get_plan_cache_size,'.size is a read-only property showing the number of plans currently in the ''cache. To change the cache capacity, set cufft_plan_cache.max_size.')max_size=cuFFTPlanCacheAttrContextProp(torch._cufft_get_plan_cache_max_size,torch._cufft_set_plan_cache_max_size)defclear(self):returntorch._cufft_clear_plan_cache(self.device_index)classcuFFTPlanCacheManager(object):r""" Represents all cuFFT plan caches. When indexed with a device object/index, this object returns the `cuFFTPlanCache` corresponding to that device. Finally, this object, when used directly as a `cuFFTPlanCache` object (e.g., setting the `.max_size`) attribute, the current device's cuFFT plan cache is used. """__initialized=Falsedef__init__(self):self.caches=[]self.__initialized=Truedef__getitem__(self,device):index=torch.cuda._utils._get_device_index(device)ifindex<0orindex>=torch.cuda.device_count():raiseRuntimeError(("cufft_plan_cache: expected 0 <= device index < {}, but got ""device with index {}").format(torch.cuda.device_count(),index))iflen(self.caches)==0:self.caches.extend(cuFFTPlanCache(index)forindexinrange(torch.cuda.device_count()))returnself.caches[index]def__getattr__(self,name):returngetattr(self[torch.cuda.current_device()],name)def__setattr__(self,name,value):ifself.__initialized:returnsetattr(self[torch.cuda.current_device()],name,value)else:returnsuper(cuFFTPlanCacheManager,self).__setattr__(name,value)classcuBLASModule:def__getattr__(self,name):assertname=="allow_tf32","Unknown attribute "+namereturntorch._C._get_cublas_allow_tf32()def__setattr__(self,name,value):assertname=="allow_tf32","Unknown attribute "+namereturntorch._C._set_cublas_allow_tf32(value)cufft_plan_cache=cuFFTPlanCacheManager()matmul=cuBLASModule()
Docs
Access comprehensive developer documentation for PyTorch
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.