Tensors and Neural Networks with 'GPU' Acceleration
Overview
Provides functionality to define and train neural networks similar to 'PyTorch' by Paszke et al (2019) doi:10.48550/arXiv.1912.01703 but written entirely in R using the 'libtorch' library. Also supports low-level tensor operations and 'GPU' acceleration.
Breaking changes
- Updated to LibTorch 2.8.0 (#1419).
torch_triu_indices()andtorch_tril_indices()now return 1-based indexes (#1382).$indices()now returns 1-based indexes (#1382).
New features
- Added
torch_sitrep()for torch installation situation report (#1415, @cregouby). - Added
%*%operator for torch tensors (#1379, @caio-hamamura). - Added
head()andtail()methods for torch tensors (#1388). - Exported
torch_scaled_dot_product_attention()(#1404). - Exported
torch_sparse_sampled_addmm()(#1427). - Exported
torch_ldexp()(#1407). - Integrated
cudatoolkitR package for CUDA library loading (#1422).
Show all changes in 0.17.0Hide the rest of the changes in 0.17.0
- Improved
as_array()support for sparse tensors (#1387).
Bug fixes
- Fixed sparse CSR tensor printing,
to_sparse()crash, andas_array()detection (#1431). - Fixed
dataset()/nn_module()crash wheninitializeparameter is namedd(#1424, @Chandraveer-Singh). - Fixed
bfloat16not being recognized as a floating point dtype (#1408). - Fixed handling of R longjump exceptions in autograd and tracing callbacks (#1406).
- Fixed redundant
lantern.hinclude causing macro redefinition warning (#1430). - Excluded glibc libraries from dependency bundling (#1397, @troyhernandez).
- Replaced non-API entry point
Rf_findVarInFramewithR_getVarExfor R 4.6 compatibility (#1421). - Added French translations for 5 missing messages (#1385, @cregouby).
From NEWS.md in the release
Install
Health
NOTERd contentsr-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc
Rd files without \usage: ‘torch_argmax.Rd’ ‘torch_argmin.Rd’ ‘torch_bincount.Rd’ ‘torch_eig.Rd’ ‘torch_logical_not.Rd’ ‘torch_lstsq.Rd’ ‘torch_matrix_rank.Rd’ ‘torch_max.Rd’ ‘torch_min.Rd’ ‘torch_sort.Rd’ \arguments should not be documented without \usage.
- NOTE11 OK, 2 NOTENow
- NOTE12 OK, 1 NOTE2026-07-11
- OK12 OK, 1 FAILURE2026-06-08
- ERROR12 OK, 1 ERROR2026-06-07
- OK13 OK2026-05-02
- NOTE11 OK, 3 NOTE2026-04-22
Show 4 earlier changesHide 4 earlier changes
- ERROR10 OK, 3 NOTE, 1 ERROR2026-04-18
- NOTE11 OK, 3 NOTE2026-04-16
- WARNING6 OK, 7 NOTE, 1 WARNING2026-03-21
- NOTE11 OK, 3 NOTE2026-03-10
Documentation
The repository also keeps web-only articles.
- Help pages
- 702 (4 internal)
- Examples that run
- 100%442 run in a plain check (1 of them under a condition)
- Exported functions with examples
- 64%
- Documented parameters
- 100%
- Return-value docs
- 6%
- Help pages citing references
- 0%
- Installation HTML
Downloads
Repository
- PRs merged (all time)
- 93%
- Median days to close, 50 most recently updated closed issues
- 5
- Median days to close, 50 most recently updated closed PRs
- 1
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
Commits over time
Commit identities over time
10 development-tooling and community-health practices detected across 5 families in the upstream repository
Checks run against github.com/mlverse/torch on 2026-10-18.
The R CMD check workflow runs on Linux, macOS and Windows
GitHub Pages site last deployed 2026-10-14 · The repository has a site deploy workflow
pkgdown site last built 2026-04-11
Show all practicesHide 1 practice
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-01-26Seen in the repository: .claude, .claude/skillsNamed in .Rbuildignore: .claudePull request it wrote: opened by a project memberCommits: at least 9 crediting it in the message
- GitHub Copilotfirst seen 2026-01-26Pull request: opened by its own accountCommits: 1 by its own account · at least 1 crediting it in the message
- Claude CodePull requests: 2 from outside contributors, first on 2026-01-12, 2 from forks
- Claude Opus 4.56 commits · Jan to Apr 2026
- Claude Opus 52 commits · Aug 2026
- Claude Opus 5.51 commit · Oct 2026
Dependencies
Installing torch adds 23 packages (11 with compiled code, 8.7 MB of source tarballs). Heaviest: Rcpp 1.8 MB, farver 1.2 MB, viridisLite 1.2 MB.
Show the 48 most downloaded dependentsHide the 48 most downloaded dependents
and 5 more dependents and 33 packages that suggest it on CRAN ↗
Code & Tests
People & History
Previously maintained by Daniel Falbel (0.0.1 to 0.16.3).
Pick two releases to compare their code metrics.
- RR 4.6.0 released · 2026-04-24
- 0.17.0Latest2026-04-11 · current release · diff ↗ ·
added 6 exports
install_torch_sitrep, torch_float8_e4m3fn, torch_float8_e5m2, torch_ldexp, torch_scaled_dot_product_attention, torch_sparse_sampled_addmm - 0.16.32025-11-02 · diff ↗
- 0.16.22025-10-31 · diff ↗
- 0.16.12025-10-16 · diff ↗
- 0.16.02025-08-21 · diff ↗
- 0.15.12025-07-10 · diff ↗
- 0.15.02025-06-23 · diff ↗ ·
added 8 exports
cuda_dump_memory_snapshot, cuda_memory_snapshot, cuda_record_memory_history, nn_aum_loss, nn_transformer_encoder, nn_transformer_encoder_layer, nnf_area_under_min_fpr_fnr, torch_bfloat16 - RR 4.5.0 released · 2025-04-11
- 0.14.22025-02-14 · diff ↗
- 0.14.12025-02-03 · diff ↗
- 0.14.02025-01-30 · diff ↗ ·
added 11 exports
OptimizerIgnite, jit_serialize, jit_unserialize, optim_ignite_adagrad, optim_ignite_adam, optim_ignite_adamw, optim_ignite_rmsprop, optim_ignite_sgd, optim_required, optimizer_ignite, torch_take_along_dim - 0.13.02024-05-22 · diff ↗ ·
added 4 exports
clone_module, linalg_solve_triangular, set_autocast, unset_autocast - RR 4.4.0 released · 2024-04-24
- 0.12.02023-12-15 · diff ↗ ·
removed 1 export
torch_symeigadded 5 exports
iterable_dataset, lr_cosine_annealing, torch_cfloat128, torch_chalf, torch_serialize - 0.11.02023-06-06 · diff ↗ ·
added 12 exports
buffer_from_torch_tensor, cuda_get_rng_state, cuda_set_rng_state, jit_ops, local_device, local_torch_manual_seed, nn_module_dict, nn_utils_weight_norm, torch_set_rng_state, torch_tensor_from_buffer, with_device, with_torch_manual_seed
Show 27 earlier eventsHide 27 earlier events
- RR 4.3.0 released · 2023-04-21
- 0.10.02023-04-14 · diff ↗ ·
removed 3 exports
torch_eig, torch_lstsq, torch_matrix_rankadded 9 exports
cuda_amp_grad_scaler, local_autocast, local_enable_grad, local_no_grad, nn_silu, nnf_silu, optim_adamw, torch_get_rng_state, with_autocast - 0.9.1
- 0.9.02022-10-24 · diff ↗ ·
removed 1 export
torch_solveadded 3 exports
backends_mps_is_available, cuda_empty_cache, cuda_synchronize - 0.8.12022-08-19 · diff ↗
- 0.8.02022-06-10 · diff ↗ ·
added 10 exports
lr_reduce_on_plateau, nn_embedding_bag, nn_prune_head, sampler, torch_cdouble, torch_cfloat, torch_cfloat32, torch_cfloat64, torch_kron, torch_lu_unpack - RR 4.2.0 released · 2022-04-22
- 0.7.22022-02-26 · diff ↗
- 0.7.1
- 0.7.02022-02-18 · diff ↗ ·
added 11 exports
backends_cudnn_is_available, backends_cudnn_version, call_torch_function, cuda_get_device_capability, cuda_memory_stats, cuda_memory_summary, jit_save_for_mobile, nn_flatten, nn_unflatten, nn_upsample, torch_install_path - 0.6.02021-10-07 · diff ↗
- 0.5.02021-08-17 · diff ↗ ·
added 36 exports
contrib_sort_vertices, jit_compile, jit_scalar, jit_trace_module, jit_tuple, linalg_cholesky, linalg_cholesky_ex, linalg_cond, linalg_det, linalg_eig, linalg_eigh, linalg_eigvals, linalg_eigvalsh, linalg_householder_product, linalg_inv, linalg_inv_ex, linalg_lstsq, linalg_matrix_norm, linalg_matrix_power, linalg_matrix_rank, linalg_multi_dot, linalg_norm, linalg_pinv, linalg_qr, linalg_slogdet, linalg_solve, linalg_svd, linalg_svdvals, linalg_tensorinv, linalg_tensorsolve and 6 more - 0.4.02021-06-10 · diff ↗ ·
added 4 exports
distr_categorical, distr_mixture_same_family, distr_multivariate_normal, torch_diff - RR 4.1.0 released · 2021-05-18
- 0.3.02021-04-28 · diff ↗ ·
removed 4 exports
torch_fft, torch_ifft, torch_irfft, torch_rfftadded 17 exports
backends_mkl_is_available, backends_mkldnn_is_available, backends_openmp_is_available, distr_bernoulli, distr_chi2, distr_gamma, distr_normal, distr_poisson, get_install_libs_url, install_torch_from_file, nn_group_norm, nn_layer_norm, optimizer, torch_fft_fft, torch_fft_ifft, torch_fft_irfft, torch_fft_rfft - 0.2.12021-01-05 · diff ↗
- 0.2.02020-12-15 · diff ↗ ·
added 88 exports
as_iterator, dataset_subset, jit_load, jit_save, jit_trace, loop, nn_batch_norm3d, nn_gru, nn_lstm, optim_lbfgs, torch_absolute, torch_acosh, torch_amax, torch_amin, torch_arccos, torch_arccosh, torch_arcsin, torch_arcsinh, torch_arctan, torch_arctanh, torch_asinh, torch_atanh, torch_atleast_1d, torch_atleast_2d, torch_atleast_3d, torch_block_diag, torch_bucketize, torch_channel_shuffle, torch_clip, torch_clone and 58 more - 0.1.12020-10-20 · diff ↗ ·
added 14 exports
nn_contrib_sparsemax, nn_utils_clip_grad_norm_, nn_utils_clip_grad_value_, nnf_contrib_sparsemax, optim_adadelta, optim_adagrad, optim_asgd, optim_rmsprop, optim_rprop, torch_get_num_interop_threads, torch_get_num_threads, torch_scalar_tensor, torch_set_num_interop_threads, torch_set_num_threads - 0.1.02020-09-28 · diff ↗ ·
added 30 exports
is_nn_buffer, is_nn_module, is_nn_parameter, is_optimizer, lr_lambda, lr_multiplicative, lr_one_cycle, lr_scheduler, lr_step, nn_bce_with_logits_loss, nn_buffer, nn_cosine_embedding_loss, nn_ctc_loss, nn_hinge_embedding_loss, nn_kl_div_loss, nn_l1_loss, nn_margin_ranking_loss, nn_mse_loss, nn_multi_margin_loss, nn_multilabel_margin_loss, nn_multilabel_soft_margin_loss, nn_nll_loss, nn_pairwise_distance, nn_parameter, nn_poisson_nll_loss, nn_smooth_l1_loss, nn_soft_margin_loss, nn_triplet_margin_loss, nn_triplet_margin_with_distance_loss, nnf_triplet_margin_with_distance_loss - unarchivedReturned to CRAN2020-09-18
- 0.0.32020-09-18 · diff ↗ ·
added 6 exports
%>%, is_torch_device, is_undefined_tensor, torch_celu, torch_relu, torch_selu - archivedRemoved from CRAN2020-09-13check issues still had not been corrected
- unarchivedReturned to CRAN2020-08-31
- 0.0.22020-08-31 · diff ↗ ·
added 22 exports
load_state_dict, nn_adaptive_avg_pool1d, nn_adaptive_avg_pool2d, nn_adaptive_avg_pool3d, nn_adaptive_max_pool1d, nn_adaptive_max_pool2d, nn_adaptive_max_pool3d, nn_avg_pool1d, nn_avg_pool2d, nn_avg_pool3d, nn_fractional_max_pool2d, nn_fractional_max_pool3d, nn_lp_pool1d, nn_lp_pool2d, nn_max_pool3d, nn_max_unpool1d, nn_max_unpool2d, nn_max_unpool3d, nnf_sigmoid, torch_finfo, torch_iinfo, torch_manual_seed - archivedRemoved from CRAN2020-08-26check issues were not corrected in time Installation failures with parallel make
- 0.0.12020-08-06
- RR 4.0.0 released · 2020-04-24
Package metadata
- First published
- 2020-08-06
- Total releases
- 32 / 6 yrs
- License
- MIT + file LICENSE OSI
- Download size
- 1.9 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("torch")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.