Beispiel #1
0
        public DeviceState(int deviceId)
        {
            CudaContext = new CudaContext(deviceId);
            DeviceInfo  = CudaContext.GetDeviceInfo();

            BlasHandles = new ObjectPool <CudaBlas>(1, () =>
            {
                CudaContext.SetCurrent();
                return(new CudaBlas());
            },
                                                    blas => blas.Dispose());

            MemoryAllocator = new PoolingDeviceAllocator(CudaContext);
            ScratchSpace    = AllocScratchSpace(CudaContext, DeviceInfo);
        }
Beispiel #2
0
        public DeviceState(int deviceId, float memoryUsageRatio = 0.9f)
        {
            this.CudaContext = new CudaContext(deviceId);
            this.DeviceInfo  = this.CudaContext.GetDeviceInfo();

            this.BlasHandles = new ObjectPool <CudaBlas>(1, () =>
            {
                this.CudaContext.SetCurrent();
                return(new CudaBlas());
            },
                                                         blas => blas.Dispose());

            this.MemoryAllocator = new PoolingDeviceAllocator(this.CudaContext, memoryUsageRatio);
            this.ScratchSpace    = AllocScratchSpace(this.CudaContext, this.DeviceInfo);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DeviceState"/> class.
        /// </summary>
        /// <param name="deviceId">The device identifier.</param>
        public DeviceState(int deviceId)
        {
            this.CudaContext = new CudaContext(deviceId);
            this.DeviceInfo  = this.CudaContext.GetDeviceInfo();

            this.BlasHandles = new ObjectPool <CudaBlas>(2, () =>
            {
                CudaContext.SetCurrent();
                return(new CudaBlas());
            },
                                                         blas => blas.Dispose());

            this.DnnHandles = new ObjectPool <ManagedCuda.CudaDNN.CudaDNNContext>(2, () =>
            {
                CudaContext.SetCurrent();
                return(new ManagedCuda.CudaDNN.CudaDNNContext());
            },
                                                                                  dnn => dnn.Dispose());

            this.MemoryAllocator = new PoolingDeviceAllocator(CudaContext);
            this.ScratchSpace    = AllocScratchSpace(CudaContext, DeviceInfo);
        }