CLI script to gather environment info (#2699)
* add "info" command to CLI As a convenience, add the info directive to CLI. Running `python transformers-cli info` will return a string containing the transformers version, platform, python version, PT/TF version and GPU support * Swap f-strings for .format Still supporting 3.5 so can't use f-strings (sad face) * Add reference in issue to CLI * Add the expected fields to issue template This way, people can still add the information manually if they want. (Though I fear they'll just ignore it.) * Remove heading from output * black-ify * order of imports Should ensure isort test passes * use is_X_available over import..pass * style * fix copy-paste bug * Rename command info -> env Also adds the command to CONTRIBUTING.md in "Did you find a bug" section
This commit is contained in:
18
.github/ISSUE_TEMPLATE/bug-report.md
vendored
18
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@@ -39,12 +39,14 @@ Steps to reproduce the behavior:
|
|||||||
|
|
||||||
<!-- A clear and concise description of what you would expect to happen. -->
|
<!-- A clear and concise description of what you would expect to happen. -->
|
||||||
|
|
||||||
## Environment
|
## Environment info
|
||||||
|
<!-- You can run the command `python transformers-cli env` and copy-and-paste its output below.
|
||||||
|
Don't forget to fill out the missing fields in that output! -->
|
||||||
|
|
||||||
* OS:
|
- `transformers` version:
|
||||||
* Python version:
|
- Platform:
|
||||||
* PyTorch version:
|
- Python version:
|
||||||
* `transformers` version (or branch):
|
- PyTorch version (GPU?):
|
||||||
* Using GPU ?
|
- Tensorflow version (GPU?):
|
||||||
* Distributed or parallel setup ?
|
- Using GPU in script?:
|
||||||
* Any other relevant information:
|
- Using distributed or parallel set-up in script?:
|
||||||
|
|||||||
21
.github/ISSUE_TEMPLATE/migration.md
vendored
21
.github/ISSUE_TEMPLATE/migration.md
vendored
@@ -33,16 +33,21 @@ The tasks I am working on is:
|
|||||||
Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.
|
Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
## Environment
|
## Environment info
|
||||||
|
<!-- You can run the command `python transformers-cli env` and copy-and-paste its output below.
|
||||||
|
Don't forget to fill out the missing fields in that output! -->
|
||||||
|
|
||||||
* OS:
|
- `transformers` version:
|
||||||
* Python version:
|
- Platform:
|
||||||
* PyTorch version:
|
- Python version:
|
||||||
|
- PyTorch version (GPU?):
|
||||||
|
- Tensorflow version (GPU?):
|
||||||
|
- Using GPU in script?:
|
||||||
|
- Using distributed or parallel set-up in script?:
|
||||||
|
|
||||||
|
<!-- IMPORTANT: which version of the former library do you use? -->
|
||||||
* `pytorch-transformers` or `pytorch-pretrained-bert` version (or branch):
|
* `pytorch-transformers` or `pytorch-pretrained-bert` version (or branch):
|
||||||
* `transformers` version (or branch):
|
|
||||||
* Using GPU?
|
|
||||||
* Distributed or parallel setup?
|
|
||||||
* Any other relevant information:
|
|
||||||
|
|
||||||
## Checklist
|
## Checklist
|
||||||
|
|
||||||
|
|||||||
@@ -41,14 +41,10 @@ Did not find it? :( So we can act quickly on it, please follow these steps:
|
|||||||
less than 30s;
|
less than 30s;
|
||||||
* Provide the *full* traceback if an exception is raised.
|
* Provide the *full* traceback if an exception is raised.
|
||||||
|
|
||||||
To get the OS and software versions, execute the following code and copy-paste
|
To get the OS and software versions automatically, you can run the following command:
|
||||||
the output:
|
|
||||||
|
|
||||||
```
|
```bash
|
||||||
import platform; print("Platform", platform.platform())
|
python transformers-cli env
|
||||||
import sys; print("Python", sys.version)
|
|
||||||
import torch; print("PyTorch", torch.__version__)
|
|
||||||
import tensorflow; print("Tensorflow", tensorflow.__version__)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Do you want to implement a new model?
|
### Do you want to implement a new model?
|
||||||
|
|||||||
58
src/transformers/commands/env.py
Normal file
58
src/transformers/commands/env.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import platform
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
|
from transformers import __version__ as version
|
||||||
|
from transformers import is_tf_available, is_torch_available
|
||||||
|
from transformers.commands import BaseTransformersCLICommand
|
||||||
|
|
||||||
|
|
||||||
|
def info_command_factory(_):
|
||||||
|
return EnvironmentCommand()
|
||||||
|
|
||||||
|
|
||||||
|
class EnvironmentCommand(BaseTransformersCLICommand):
|
||||||
|
@staticmethod
|
||||||
|
def register_subcommand(parser: ArgumentParser):
|
||||||
|
download_parser = parser.add_parser("env")
|
||||||
|
download_parser.set_defaults(func=info_command_factory)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pt_version = "not installed"
|
||||||
|
pt_cuda_available = "NA"
|
||||||
|
if is_torch_available():
|
||||||
|
import torch
|
||||||
|
|
||||||
|
pt_version = torch.__version__
|
||||||
|
pt_cuda_available = torch.cuda.is_available()
|
||||||
|
|
||||||
|
tf_version = "not installed"
|
||||||
|
tf_cuda_available = "NA"
|
||||||
|
if is_tf_available():
|
||||||
|
import tensorflow as tf
|
||||||
|
|
||||||
|
tf_version = tf.__version__
|
||||||
|
try:
|
||||||
|
# deprecated in v2.1
|
||||||
|
tf_cuda_available = tf.test.is_gpu_available()
|
||||||
|
except AttributeError:
|
||||||
|
# returns list of devices, convert to bool
|
||||||
|
tf_cuda_available = bool(tf.config.list_physical_devices("GPU"))
|
||||||
|
|
||||||
|
info = {
|
||||||
|
"`transformers` version": version,
|
||||||
|
"Platform": platform.platform(),
|
||||||
|
"Python version": platform.python_version(),
|
||||||
|
"PyTorch version (GPU?)": "{} ({})".format(pt_version, pt_cuda_available),
|
||||||
|
"Tensorflow version (GPU?)": "{} ({})".format(tf_version, tf_cuda_available),
|
||||||
|
"Using GPU in script?": "<fill in>",
|
||||||
|
"Using distributed or parallel set-up in script?": "<fill in>",
|
||||||
|
}
|
||||||
|
|
||||||
|
print("\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n")
|
||||||
|
print(self.format_dict(info))
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def format_dict(d):
|
||||||
|
return "\n".join(["- {}: {}".format(prop, val) for prop, val in d.items()]) + "\n"
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
from transformers.commands.download import DownloadCommand
|
|
||||||
from transformers.commands.run import RunCommand
|
|
||||||
from transformers.commands.user import UserCommands
|
|
||||||
from transformers.commands.convert import ConvertCommand
|
from transformers.commands.convert import ConvertCommand
|
||||||
|
from transformers.commands.download import DownloadCommand
|
||||||
|
from transformers.commands.env import EnvironmentCommand
|
||||||
|
from transformers.commands.run import RunCommand
|
||||||
from transformers.commands.serving import ServeCommand
|
from transformers.commands.serving import ServeCommand
|
||||||
|
from transformers.commands.user import UserCommands
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = ArgumentParser('Transformers CLI tool', usage='transformers-cli <command> [<args>]')
|
parser = ArgumentParser('Transformers CLI tool', usage='transformers-cli <command> [<args>]')
|
||||||
@@ -14,6 +15,7 @@ if __name__ == '__main__':
|
|||||||
# Register commands
|
# Register commands
|
||||||
ConvertCommand.register_subcommand(commands_parser)
|
ConvertCommand.register_subcommand(commands_parser)
|
||||||
DownloadCommand.register_subcommand(commands_parser)
|
DownloadCommand.register_subcommand(commands_parser)
|
||||||
|
EnvironmentCommand.register_subcommand(commands_parser)
|
||||||
RunCommand.register_subcommand(commands_parser)
|
RunCommand.register_subcommand(commands_parser)
|
||||||
ServeCommand.register_subcommand(commands_parser)
|
ServeCommand.register_subcommand(commands_parser)
|
||||||
UserCommands.register_subcommand(commands_parser)
|
UserCommands.register_subcommand(commands_parser)
|
||||||
|
|||||||
Reference in New Issue
Block a user