Sample questions
Aipy Python Ml Packaging EnvironmentsDifficulty 1
In an ML project, why is it common practice to create a dedicated virtual environment (venv or conda env) instead of installing packages like torch or numpy into the system-wide Python?
- aBecause system-wide Python cannot run any machine learning code at all, regardless of installed packages.
- bSo each project's package versions stay isolated, avoiding conflicts between projects.✓
- cBecause pip refuses to install GPU-related packages outside of a virtual environment.
- dSo the operating system automatically updates all ML libraries to their latest version every night.
Explanation:A dedicated environment isolates each project's dependency set, so one project's numpy or torch version doesn't collide with another's requirements on the same machine. (a) is false — system Python can run ML code, isolation is about conflict avoidance, not capability. (c) invents a pip restriction that doesn't exist. (d) describes automatic upgrades, which is unrelated to what environments do.
Aipy Python Ml Packaging EnvironmentsDifficulty 1
What is the main practical difference between pip and conda when managing dependencies for an ML project?
- aconda can manage non-Python dependencies (like CUDA toolkit libraries) in addition to Python packages.✓
- bpip can only be used inside a Docker container, while conda can only be used on a bare-metal machine.
- cconda always installs strictly newer package versions than pip, regardless of what is requested.
- dpip and conda are two names for the exact same tool, so the distinction has no practical effect.
Explanation:conda manages full binary packages, including non-Python system-level libraries such as CUDA/cuDNN builds, whereas pip's scope is limited to Python packages. (b) fabricates a container-only restriction that doesn't exist. (c) invents a version-ordering rule pip/conda don't follow. (d) is false — they are different tools with different dependency resolvers and package formats.
Aipy Python Ml Packaging EnvironmentsDifficulty 1
What does the command pip freeze typically output, and why is it useful for ML projects?
- aA list of every package ever released on PyPI, useful for browsing available ML libraries.
- bThe GPU driver version installed on the machine, useful for checking CUDA compatibility.
- cThe exact installed package versions in the current environment.✓
- dA performance benchmark of the current environment's numpy and torch installations.
Explanation:pip freeze lists the exact versions of packages currently installed, which is commonly redirected into a requirements file so the same environment can be reproduced elsewhere. (a) confuses it with browsing the entire PyPI catalog. (b) and (d) attribute driver-inspection or benchmarking behavior that pip freeze does not perform.
Aipy Python Ml Packaging EnvironmentsDifficulty 2
A team's requirements.txt lists numpy>=1.20. Six months later, a fresh install pulls a much newer numpy that changes some default behavior, breaking a training script that worked before. What does this illustrate?
- arequirements.txt files can only ever contain one dependency, so this project was already misconfigured.
- bnumpy versions are always fully backward compatible, so the breakage must be caused by something unrelated to the version bump.
- cpip ignores version constraints like
>= after the first install, so this behavior is actually a pip bug. - dA loose constraint like
>= allows a newer, behavior-changing version to be installed later, hurting reproducibility.✓
Explanation:>= only sets a floor, so any newer release satisfies it — including one with breaking changes — which is exactly why loose constraints undermine reproducibility over time. (a) is false; requirements files can list many dependencies. (b) wrongly assumes perfect backward compatibility across all versions. (c) fabricates a pip bug rather than recognizing normal >= resolution behavior.
Aipy Python Ml Packaging EnvironmentsDifficulty 2
Why does installing a GPU-accelerated deep learning framework typically require checking the machine's CUDA/driver version first, rather than just running pip install torch?
- aBecause pip cannot install any package larger than 500 MB without manual driver configuration.
- bPrebuilt GPU wheels are compiled against a specific CUDA version range, and an incompatible setup can silently break GPU support.✓
- cBecause CUDA versions are only relevant for training, never for running inference on a GPU.
- dBecause
pip install torch always installs every CUDA version simultaneously, so compatibility never matters.
Explanation:Prebuilt GPU wheels target a specific CUDA build, and mismatches with the installed driver/CUDA runtime commonly lead to the framework silently falling back to CPU or raising errors, so checking compatibility first matters. (a) invents a package-size restriction unrelated to CUDA. (c) wrongly claims CUDA compatibility only matters for training. (d) misrepresents pip as bundling all CUDA versions at once.
Aipy Python Ml Packaging EnvironmentsDifficulty 2
In addition to numpy.random.seed(...), why might a training script also need random.seed(...) (Python's built-in random module) and torch.manual_seed(...) set separately?
- aEach library maintains its own independent random number generator state.✓
- bSetting numpy's seed automatically propagates the same seed to every other installed library.
- cPython's built-in
random module is deprecated and setting its seed has no effect on modern systems. - dtorch reads its seed exclusively from the operating system clock and ignores any seed passed to it.
Explanation:random, numpy, and torch each keep their own separate RNG state internally, so a seed set on one has no effect on the others — reproducibility requires seeding every library that generates randomness. (b) invents automatic propagation that doesn't exist. (c) is false; random is a standard, actively used module. (d) misrepresents torch.manual_seed, which does take and use the seed passed to it.